tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: devel/py-joblib patch



On 1/10/24 20:40, Taylor R Campbell wrote:
OK, but for NetBSD today, why is running `sysctl hw.ncpu' in a
subprocess better than calling os.sysconf('SC_NPROCESSORS_CONF')?


It's not, but this is a temporary fix, so I just followed the pattern
for other platforms.  It will be changed to the number of physical cores
once that's possible, which will require a sysctl, unless a non-standard
sysconf variable is added.

This routine should be called infrequently (ideally once per process),
so performance is not a major concern anyway.

They are always the same, because sysconf(_SC_NPROCESSORS_CONF) in
libc just queries hw.ncpu (but with substantially less overhead than
running a subprocess).

Maybe tomorrow we'll add hw.ncoresnotcountingthreads or whatever, but
I'm confused why you say you have to stick with subprocesses and not
os.sysconf for now.

Did you see Martin's suggestion to expose the low-level kernel data
rather the compute core counts?  I think this is a good approach, as it
minimizes complexity in the OS, and maximizes flexibility for the user,
albeit with a small amount of work.


Home | Main Index | Thread Index | Old Index