I realize that this will largely depend on the processes in question, but is there a rule of thumb?
Say I have a multi-threaded program called progX
that offers a command line switch (--cpu
) controlling the number of CPUs it can use. Is it faster to launch 40 parallel instances using one CPU each (progX --cpu 1
) or to launch a single instance, telling it to use 40 CPUs (progX --cpu 40
)?
it is faster to lauch a single instance by far. Threads are made for that purpose, and they are lighter that processes. The de-facto rule is: let the OS do the scheduling and memory management unless you need to do the dirty job by yourself. This way your code will be much simpler and cleaner. The OS has a bunch of lower level tools to handle processes and memory much more efficiently. Of course it will depend on the OS, but this is a general rule for modern OS, and at least the one i use (Linux).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With