bug-coreutils@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Simon Heimberg <simon.heimberg@heimberg-ea.ch>
To: 65697@debbugs.gnu.org
Subject: bug#65697: numproc, add flag to get numer of available cores
Date: Sat, 02 Sep 2023 11:38:46 +0200	[thread overview]
Message-ID: <4ac01182f059e836885b9604a367e00157b80730.camel@heimberg-ea.ch> (raw)

Hello

Depending on what a process is mainly limited by, the ideal number of
processes to run concurrently varies.
A frequent use case is to run one process on each _physical_ core
(which is available) than on each logical processing unit.
I propose to introduce a flag --core which returns the number of
physical cores available to the process (or of all cores with --all).

I made a draft in python using getaffinity(), assuming the threads of a
core are listed after each other:
https://github.com/giampaolo/psutil/issues/1968#issuecomment-1688687251

Looking at the code in gnulib/lib/nproc.c this could get hard to
implement for all cases. (Many cases. No list for physical cores exists
yet.)

Maybe it is better to extend the doc and explain what the number really
means (with and without --all). Or add a link to more details about
processors and cores and ... . Extended doc could improve:
* As #42044 complains that nproc does not include the cores which go
online automatically. (The current help text _could_ match this.)
* As I complain that nproc can not report (available) _physical_ cores.
* I just found out (partially) why --all shows more cpus than are in my
system. (It returns the _configured_ ones. And those get set ...:
https://unix.stackexchange.com/questions/609555/how-does-linux-detect-number-of-possible-cpus
) But the help writes "installed processors", not configured ones. (On
my system, processors which are configured only are not listed by ls -l
/sys/devices/system/cpu/cpu*)


About better using one process for each core, depending on ...:
https://github.com/giampaolo/psutil/issues/1968
https://stackoverflow.com/questions/27404532/optimal-number-of-processes
https://stackoverflow.com/questions/36958661/openmp-dont-use-hyperthreading-cores-half-num-threads-w-hyperthreading





             reply	other threads:[~2023-09-02 11:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-02  9:38 Simon Heimberg [this message]
2023-09-02 14:08 ` bug#65697: numproc, add flag to get number of available cores Pádraig Brady

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-coreutils

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ac01182f059e836885b9604a367e00157b80730.camel@heimberg-ea.ch \
    --to=simon.heimberg@heimberg-ea.ch \
    --cc=65697@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).