Skip to content

Cores Reporting

This page describes how cores are counted for reporting to KX.

KX products can be licensed by number of cores. Cores are counted in both physical and virtual environments, including orchestrated environments like Kubernetes and Docker.

An example script is provided to guide you on how to report the number of licensed cores to KX in Unix environments.

Environments

The following sections describe how to report core usage based on your environment.

Unix

KX uses the following calculation method to measure cores on a Unix-based operating system. Both the threads per core and the cores per socket are considered.

(sockets) x (cores-per-socket) x (threads-per-core) = (total-cores)

For example, using the lscpu command:

lscpu | grep -E '^Thread|^Core|^Socket\('

Gives the following result.

Thread(s) per core:                 2
Core(s) per socket:                 4
Socket(s):                          1

Using the calculation method above, (1 x 4 x 2) = 8 cores in total.

The use of taskset to set CPU affinity for kdb+ and q processes is only permitted when a KX license is limited to a set number of cores. Any other configurations using taskset for kdb+ and q processes are considered excess usage. For more details, refer to the KX Software Usage Terms for Cores.

Unix cores reporting

The following example script returns a report for the number of processors and cores in use in a Unix server estate. This needs to be run on each server as root, or under the username running kdb+ and q for a deployment where licensed KX software is running.

This script runs through the following steps:

  • Sets up a table header for the total number of processors and the core range applied to them.
  • Retrieves the process ids for running q processes.
  • Extracts the taskset affinity for each process.
  • Sorts and formats into list of processors and cores.

Example script

printf "Total Processors\tCore Range\n$(for pid in $(ps -ef | awk '$8=="q" {print $2}' ); do taskset -pc $pid 2>/dev/null; done | awk '{print $6}' | sort | uniq -c | awk {'printf ("%s\t\t\t%s\n", $1, $2)'})\n"

Report output

Total Processors        Core Range
1                       2
1                       4
1                       7

Windows

Open PowerShell and bring up the wmic interface:

PS C:\Users\kx> wmic

Type the command below at the wmic interface prompt:

wmic:root\cli>CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List

NumberOfCores=10
NumberOfLogicalProcessors=12

The reported number of processors includes the logical processors, with hyperthreading enabled, so the core count is 12 in total.

MacOS

In a terminal session, run the system profiler. Enter the command below:

system_profiler SPHardwareDataType | grep "Cores"

Press Return. A message is displayed, similar to the following example, informing you of the number of cores available on the Mac CPU:

Total Number of Cores: 8 (4 performance and 4 efficiency)

This shows that there are 8 cores in total.

Containerized environments

The following section describes the cores repoting process if you using a containerized deployment.

Docker

In Docker environments, a CPU is considered as a core. Use docker inspect for each docker container used to run a KX product. Run the following command:

docker inspect your-docker-environment | grep CpusetCpus

"CpusetCpus": "0-3"

This range covers 0,1,2, and 3, giving 4 cores in total.

Fractional CPU assignation

Fractional CPU assignments in Docker are rounded to the nearest integer, so a fractional CPU count of 3.5 would round up to 4.

Kubernetes

CPUs can be read from the namespace config, for each container used to run a KX product. 1 CPU is considered as a core in the Kubernetes context. For example:

apiVersion: v1
kind: Pod
metadata:
  name: cpu-demo
  namespace: cpu-example
spec:
  containers:
  - name: cpu-demo-ctr
  image: vish/stress
  resources:
    limits:
      cpu: "2"
    requests:
      cpu: "1.5"

From the namespace config above in the resources section, cpu: "2" gives 2 cores in total.

Fractional CPU assignation

Fractional CPU assignments in Kubernetes are rounded to the nearest integer, so a fractional CPU count of 3.5 would round up to 4.