unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Campbell Barton <ideasman42@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] support for accessing CPU/core count (processor-count)
Date: Mon, 11 Oct 2021 10:01:40 +0200	[thread overview]
Message-ID: <AM9PR09MB49772E2EC8EE6AC320BAABA196B59@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <a3cc3806-f491-6c9f-d969-1a357f75f355@gmail.com> (Campbell Barton's message of "Mon, 11 Oct 2021 09:58:05 +1100")

Campbell Barton <ideasman42@gmail.com> writes:

> On 10/11/21 06:50, Arthur Miller wrote:
>> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 
>>>> We seem to be talking past each other. I don't see why would want this as a C
>>>> primitive.
>>>
>>> There are typically 2 reasons to use C:
>>> - For speed
>>> - To use someone else's code which is easily available from C but not
>>>    from ELisp.
>> Of course, but I don't see any of those apply to this case :).
>
> The Elisp version of this function posted was incomplete by comparison in that
> it didn't support OpenBSD's ncpuonline feature or HPUX.
But then complete it :). I don't have openbsd installed.

> Also, this is not simply a call to an external process (executable-find "nproc")
> has some additional overhead.
You can skip that search if you want; it was just to be on the safe side. That
overhead is not importnat. As I wrote to Omar, you will probably ask for number
of cpu's in some eval-after-load or similar, not in some performance critical
code.

> I don't see this so much a case of ELisp vs C, more a case of OS-level API's
> being more appropriate than searching around for commands and parsing their
> output.
nproc.c has already sorted all that for you; so you can just call the process
instead of doing it all over.

>> As I see nproc from core-utils is already doing suggested, and more than so, so
>> it is just to call it :).
>> https://github.com/coreutils/gnulib/blob/master/lib/nproc.c
>> PS: it is not directly "a couple of lines" either as someone suggested :).
>
> Right, it's quite involved, as mentioned in a previous reply, this seems more
> appropriate for detecting OS-level threads (not spawning new processes).

Why does os threads matter if you can't access them. Or you mean "logical cores"
a.k.a "hyperthreading"?



  reply	other threads:[~2021-10-11  8:01 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10  0:02 [PATCH] support for accessing CPU/core count (processor-count) Campbell Barton
2021-10-10  7:54 ` Omar Polo
2021-10-10  9:38   ` Arthur Miller
2021-10-10  9:43     ` Omar Polo
2021-10-10 10:52       ` Arthur Miller
2021-10-10 12:07         ` Omar Polo
2021-10-10 16:48           ` Arthur Miller
2021-10-10 18:17             ` Omar Polo
2021-10-10 19:45               ` Arthur Miller
2021-10-10 21:04                 ` Omar Polo
2021-10-11  8:15                   ` Arthur Miller
2021-10-11  8:20                   ` Arthur Miller
2021-10-11  8:23                     ` Omar Polo
2021-10-11 15:55                       ` Arthur Miller
2021-10-10 21:32                 ` Andreas Schwab
2021-10-11  8:03                   ` Arthur Miller
2021-10-11  8:14                     ` Andreas Schwab
2021-10-11 15:53                       ` Arthur Miller
2021-10-11 16:49                         ` Andreas Schwab
2021-10-11 17:14                           ` Arthur Miller
2021-10-10 10:13     ` Campbell Barton
2021-10-10 10:38     ` Andreas Schwab
2021-10-10 11:21       ` Arthur Miller
2021-10-10 11:57         ` Andreas Schwab
2021-10-10 16:35           ` Arthur Miller
2021-10-10 17:27             ` Andreas Schwab
2021-10-10 18:13               ` Arthur Miller
2021-10-10 19:16                 ` Stefan Monnier
2021-10-10 19:50                   ` Arthur Miller
2021-10-10 22:58                     ` Campbell Barton
2021-10-11  8:01                       ` Arthur Miller [this message]
2021-10-10 12:21   ` Stefan Kangas
2021-10-10 16:03     ` Omar Polo
2021-10-10 21:11     ` Paul Eggert
2021-10-10 21:16       ` Omar Polo
2021-10-11 17:17       ` Arthur Miller
2021-10-10 10:50 ` Andy Moreton
2021-10-10 11:21   ` Arthur Miller
2021-10-10 12:09 ` Stefan Kangas
2021-10-10 22:43   ` Campbell Barton
2021-10-11  1:34 ` Po Lu
2021-10-11  1:51   ` Campbell Barton
2021-10-11  3:04     ` Po Lu
2021-10-11  4:01       ` Campbell Barton
2021-10-11  8:20         ` Lars Ingebrigtsen
2021-10-11 13:00           ` Eli Zaretskii
2021-10-11 15:12           ` Stefan Monnier
2021-10-11 16:07             ` Eli Zaretskii
2021-10-11 21:14               ` Andy Moreton
2021-10-11 22:13                 ` Ken Brown
2021-10-12  2:27                 ` Eli Zaretskii
2021-10-12 10:39               ` Lars Ingebrigtsen
2021-10-12 14:09                 ` Eli Zaretskii
2021-10-12 19:58                   ` Paul Eggert
2021-10-13  2:24                     ` Eli Zaretskii

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://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=AM9PR09MB49772E2EC8EE6AC320BAABA196B59@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=ideasman42@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).