Run on specified processor cores #50541
-
Hi! I have CPU 24 cores, how can I run 1 program on 8, another on the next 8, and another on the remaining 8. In Windows I do this manually, it takes an awfully long time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Node.js itself does not provide a built-in way to set processor affinity. on windows you can use start /affinity 0xFF node program1.js
start /affinity 0xFF00 node program2.js
start /affinity 0xFF0000 node program3.js Here's what the affinity masks mean:
In PowerShell, you can use Start-Process with the -ProcessorAffinity parameter, like so: Start-Process node -ArgumentList "program1.js" -Affinity 0xFF
Start-Process node -ArgumentList "program2.js" -Affinity 0xFF00
Start-Process node -ArgumentList "program3.js" -Affinity 0xFF0000 if you use Linux then you can use taskset -c 0-7 node program1.js &
taskset -c 8-15 node program2.js &
taskset -c 16-23 node program3.js & |
Beta Was this translation helpful? Give feedback.
Node.js itself does not provide a built-in way to set processor affinity.
on windows you can use
start
command along with theaffinity
option to launch your programs with the specified CPU affinity.for example if you want ot run 3 different Node.js programs on separate groups of 8 cores, you can use the following commands in a batch file or directly in the cmd:
Here's what the affinity masks mean:
In P…