2023.03.21 02:32 PM
I'm looking for information regarding hyperthreading with kdb+, main questions below
1) Does it cause any issues when enabled?
2) Does it impact the license in any way. 3) Are there any types of queries or operations which benefit from it being enabled?
4) Is the -s flag for secondary threads impacted or operate differently
Thanks
2023.03.22 04:50 AM - edited 2023.03.22 05:06 AM
Hyperthreading does not cause problems for kdb+ but you should be aware of your core allocations to get the most out of your kdb+ licence.
Example:
Your machine will list cores 0,1,2,3,4,5,6,7.
You want to make sure you use your 4 core licence only once on each logical CPU core for best performance.
Inspecting /proc/cpuinfo
gives you the information you need.
cpuinfo:.Q.id {{{(`$x[0])!x[1]}flip {ssr[;"\t";""] each trim ":" vs x}each x y}[x] each {{x[0]+til 1+x[1]-x[0]}each flip (0^1+prev x;-1+x)}where x~\:""}system"cat /proc/cpuinfo"
select processor,physicalid,siblings,coreid,cpucores from cpuinfo
processor physicalid siblings coreid cpucores
---------------------------------------------
,"0" ,"0" ,"8" ,"0" ,"4"
,"1" ,"0" ,"8" ,"0" ,"4"
,"2" ,"0" ,"8" ,"1" ,"4"
,"3" ,"0" ,"8" ,"1" ,"4"
,"4" ,"0" ,"8" ,"2" ,"4"
,"5" ,"0" ,"8" ,"2" ,"4"
,"6" ,"0" ,"8" ,"3" ,"4"
,"7" ,"0" ,"8" ,"3" ,"4"
Here the output suggests I should use taskset 0,2,4,6 or 1,3,5,7 so that I only reuse each coreid once.
This way I am getting best usage from your kdb+ licence as each one is taxing a full core without overlap.
It's possible on another OS/machine the layout may suggest 0-3 or 4-7.
On this example if only kdb+ is running on the machine you may see a fractional perf benefit from disabling hyperthreading. It can depend on various hardware and workload variables.
Lots of discussion available online on the topic:
https://unix.stackexchange.com/questions/57920/how-do-i-know-which-processors-are-physical-cores
Note: some extra checks and verifications should be done if using Virtual Machines as they may not pass through all correct detailed information through to the VM and you may need to verify at the hypervisor level.
If you had unlimited cores licence the answer is a little more nuanced and use case specific in how you may choose to taskset your processes. Or you may choose to let not pin individual processes to cores but instead let the OS move tasks around for best efficiency.
For machines heavily taxing IO hyperthreading can help here specifically with reading of data from disk.
Once on to multi CPU systems NUMA also comes in to play and should be paid attention to.
https://code.kx.com/q/kb/linux-production/#non-uniform-memory-access-numa-hardware
2023.03.22 04:50 AM - edited 2023.03.22 05:06 AM
Hyperthreading does not cause problems for kdb+ but you should be aware of your core allocations to get the most out of your kdb+ licence.
Example:
Your machine will list cores 0,1,2,3,4,5,6,7.
You want to make sure you use your 4 core licence only once on each logical CPU core for best performance.
Inspecting /proc/cpuinfo
gives you the information you need.
cpuinfo:.Q.id {{{(`$x[0])!x[1]}flip {ssr[;"\t";""] each trim ":" vs x}each x y}[x] each {{x[0]+til 1+x[1]-x[0]}each flip (0^1+prev x;-1+x)}where x~\:""}system"cat /proc/cpuinfo"
select processor,physicalid,siblings,coreid,cpucores from cpuinfo
processor physicalid siblings coreid cpucores
---------------------------------------------
,"0" ,"0" ,"8" ,"0" ,"4"
,"1" ,"0" ,"8" ,"0" ,"4"
,"2" ,"0" ,"8" ,"1" ,"4"
,"3" ,"0" ,"8" ,"1" ,"4"
,"4" ,"0" ,"8" ,"2" ,"4"
,"5" ,"0" ,"8" ,"2" ,"4"
,"6" ,"0" ,"8" ,"3" ,"4"
,"7" ,"0" ,"8" ,"3" ,"4"
Here the output suggests I should use taskset 0,2,4,6 or 1,3,5,7 so that I only reuse each coreid once.
This way I am getting best usage from your kdb+ licence as each one is taxing a full core without overlap.
It's possible on another OS/machine the layout may suggest 0-3 or 4-7.
On this example if only kdb+ is running on the machine you may see a fractional perf benefit from disabling hyperthreading. It can depend on various hardware and workload variables.
Lots of discussion available online on the topic:
https://unix.stackexchange.com/questions/57920/how-do-i-know-which-processors-are-physical-cores
Note: some extra checks and verifications should be done if using Virtual Machines as they may not pass through all correct detailed information through to the VM and you may need to verify at the hypervisor level.
If you had unlimited cores licence the answer is a little more nuanced and use case specific in how you may choose to taskset your processes. Or you may choose to let not pin individual processes to cores but instead let the OS move tasks around for best efficiency.
For machines heavily taxing IO hyperthreading can help here specifically with reading of data from disk.
Once on to multi CPU systems NUMA also comes in to play and should be paid attention to.
https://code.kx.com/q/kb/linux-production/#non-uniform-memory-access-numa-hardware
2023.03.22 11:43 AM
Thank you Rian, excellent information there. That command is very helpful. Much appreciated
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.