Cores reporting¶
This page describes how KX counts cores for reporting.
KX licenses some products by the number of cores. KX counts cores in physical and virtual environments, including orchestrated environments such as Kubernetes and Docker.
The following example scripts show you how to report the number of licensed cores to KX in Unix environments.
Environments¶
Select 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. The calculation counts both the threads per core and the cores per socket.
(sockets) x (cores-per-socket) x (threads-per-core) = (total-cores)
For example, using the lscpu command:
lscpu | grep -E '^Thread|^Core|^Socket\('
The output is similar to the following:
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Using the preceding calculation method, (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 KX Software Usage Terms for Cores.
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. Run this 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
tasksetaffinity for each process. - Sorts the results and formats them as a list of processes and cores.
Example script¶
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¶
Total q Processes Core Range
1 2
1 4
1 7
Windows¶
Open PowerShell and start wmic:
PS C:\Users\kx> wmic
Enter the following command at the wmic prompt:
wmic:root\cli>CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List
NumberOfCores=10
NumberOfLogicalProcessors=12
With hyper-threading enabled, KX counts logical processors. In this example, that's 12 cores.
macOS¶
In a terminal session, run the system profiler. Enter the following command:
system_profiler SPHardwareDataType | grep "Cores"
Press Enter. A message similar to the following shows the number of cores available on the Mac CPU:
Total Number of Cores: 8 (4 performance and 4 efficiency)
This shows eight cores in total.
Containerized environments¶
The following sections describe the cores reporting process if you are using a containerized deployment.
Docker¶
In Docker environments, a CPU counts 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
The output is similar to the following:
"CpusetCpus": "0-3"
This range covers 0, 1, 2, and 3, giving four cores in total.
Fractional CPU assignment in Docker¶
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¶
Read CPUs from the Pod spec for each container used to run a KX product. In Kubernetes, one CPU counts as a core. 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"
In the resources section of the preceding Pod spec, cpu: "2" gives two cores in total.
Fractional CPU assignment in Kubernetes¶
Fractional CPU assignments in Kubernetes are rounded to the nearest integer, so a fractional CPU count of 3.5 would round up to 4.