plink-ng icon indicating copy to clipboard operation
plink-ng copied to clipboard

sysconf(_SC_NPROCESSORS_ONLN) should not be used

Open jbd opened this issue 2 years ago • 5 comments

Hello,

sysconf(_SC_NPROCESSORS_ONLN) returns, when possible, the underlying hardware number of online cpu cores, which might not corresponds to the actual number of cores available to the process (through the use of taskset, batch system like slurm, etc...). The consequence is that plink might run in a non optimal way. For example, I've got a user that has submitted a plink job on a 96 cores HPC nodes, in a single core slurm allocation: 95 threads are now fighting for the usage of this core.

The immediate workaround is to use the --threads option to set the number of threads, but I think a more sane behavior would be to use sched_getaffinity as in https://github.com/opencv/opencv/issues/16268. Gromacs did something similar (https://github.com/gromacs/gromacs/blob/1e6873fadf16d5f5be861e6f9ef5f9923a12e540/src/gromacs/hardware/hardwaretopology.cpp#L1221).

What do you think ?

Thank you.

jbd avatar Oct 24 '22 09:10 jbd

Okay, I will test this, and include the change in the next release if the results look good.

chrchang avatar Oct 24 '22 15:10 chrchang

Thank you for considering this !

jbd avatar Oct 24 '22 15:10 jbd

Changed in 9df631b .

chrchang avatar Oct 24 '22 20:10 chrchang

Fantastic, thank you !

My understanding is that there will be no further development on the 1.9 branch and this will not be backported, correct ?

jbd avatar Oct 25 '22 08:10 jbd

plink 1.9 is updated much less frequently than 2.0, but this change may be backported during the next update.

chrchang avatar Oct 26 '22 03:10 chrchang

Now updated in plink 1.9.

chrchang avatar Dec 11 '22 00:12 chrchang