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.

Example scripts are provided to guide you on how to report the number of licensed cores to KX in Unix environments.

Environments

Navigate to your environment to find instructions on how to report core usage based on your environment:

If you are using a containerized environment, refer to the following instructions:

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.

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

For example, using the lscpu command:

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

Gives the following result.

Copy
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.

Note

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 TBD.

Unix cores reporting

The following example script returns a report for the number of q processes 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 processes 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 processes and cores.

Example script

Copy
printf "Total q Processes\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

Copy
Total q Processes        Core Range
1                       2
1                       4
1                       7

Windows

Open PowerShell and bring up the wmic interface:

Copy
PS C:\Users\kx> wmic

Type the command below at the wmic interface prompt:

 

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

NumberOfCores=10
NumberOfLogicalProcessors=12
                   

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

MacOS

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

 

Copy
system_profiler SPHardwareDataType | grep "Cores"
                    

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

Copy
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 reporting 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:

 

Copy
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. One CPU is considered as a core in the Kubernetes context. For example:

Copy
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.