|
From: | Campbell Barton |
Subject: | Re: [PATCH] support for accessing CPU/core count (processor-count) |
Date: | Mon, 11 Oct 2021 09:43:05 +1100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
On 10/10/21 23:09, Stefan Kangas wrote:
Campbell Barton <ideasman42@gmail.com> writes:Hi, this patch adds support for accessing the number of CPU's / cores on a system, matching CPython's multiprocessing.cpu_count() [0]. I've only tested this for Linux, this includes code that should work on other platforms, although that would need to be double-checked of course. For reference I checked CPython / Blender & Stack-overflow [1] Accessing this information can be useful to automatically detect the number of jobs to run.Could we reuse the num_processors_ignoring_omp function in nproc.c in Gnulib? From a cursory look, it seems to support also e.g. HP-UX, IRIX.
This makes use of CPU affinity (where possible), which would be appropriate for Emacs spawning operating system level threads.
Since Python's multiprocessing is straightforward and widely used, following the same behavior seems reasonable.
If CPU affinity becomes an important this could be supported if/when it's needed.
[Prev in Thread] | Current Thread | [Next in Thread] |