tech-pkg archive

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

Re: devel/py-joblib patch



On 12/29/23 11:14, Jason Bacon wrote:
On 12/29/23 08:38, Martin Husemann wrote:
On Fri, Dec 29, 2023 at 08:02:44AM -0600, Jason Bacon wrote:
              cpu_count_physical = int(cpu_info)
+        # Maybe also openbsd, dragonfly, etc?
+        elif sys.platform.startswith('freebsd') or
sys.platform.startswith('netbsd'):
+            cpu_info = subprocess.run(
+                "sysctl -n hw.ncpu".split(),
+                capture_output=True,
+                text=True,
+            )
+            cpu_info = cpu_info.stdout
+            cpu_count_physical = int(cpu_info)

This sounds pretty expensive, can't it use os.sysconf(NPROCESSORS_CONF) ?

Martin

Probably.  I was just following the other examples in the code, as I'm
no pythonista, but your suggestion sounds like a better approach.

https://github.com/joblib/joblib/issues/1535



As per the github discussion, we'll have to stick with subprocesses for now. sysconf does not return the desired core count and there is no portable sysctl interface for python at this time. The pypi sysctl package is FreeBSD-specific, while completely different implementations exist for NetBSD and Linux.

Home | Main Index | Thread Index | Old Index