pigz icon indicating copy to clipboard operation
pigz copied to clipboard

number of online processors when some cores are isolated via kernel

Open tjanas opened this issue 4 years ago • 1 comments

On some of my Red Hat Linux machines, I have almost of the online cores isolated via kernel boot parameters (via isolcpus) so that they are unavailable to the OS. However, the mechanism used in pigz.c does not account for this, so it spawns far more threads than cores that are truly available.

Example, on one of my 36-core machines: /boot/grub/grub.conf kernel boot parameter 'isolcpus' has 29 cores isolated sysconf(_SC_NPROCESSORS_ONLN) returns 36 numactl --show includes a list of cores that are not isolated by the kernel (a total of 7 for this example)

Is there a way for pigz to handle this situation, where it would detect 7 online cores instead of 36 for the above machine?

tjanas avatar Mar 08 '22 17:03 tjanas

You can specify the number of threads using -p, so perhaps you can use the output of numactl to deduce the number of available cores and feed that to the command line option.

However I wonder what difference it makes. There is likely not much penalty in specifying more cores than you have, other than using more memory for the buffers in all the threads. You should test to see the difference between -p 7 and -p 32, or -p 100 for that matter. In fact, pigz invokes two more threads than requested (expect when using -p 1), one being the main thread and one being a thread to write the output. The n cores in -p n is only the number of cores for compression.

Of course, if you want the best performance, you don't want to specify fewer cores than you have, so the number of actual cores should always be safe.

madler avatar Mar 08 '22 20:03 madler