diff options
author | Eric Wong <e@80x24.org> | 2023-09-18 10:15:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-09-20 19:14:19 +0000 |
commit | 6b70d5f03b688ee24df38ea669c0d800a6ad3b49 (patch) | |
tree | 51f0bd6e3cc9739bbf9f43284fbe49fa65bc03a5 | |
parent | d6e792f9eb38258dd79eed7626b3cab1eb25cd1f (diff) | |
download | public-inbox-6b70d5f03b688ee24df38ea669c0d800a6ad3b49.tar.gz |
`getconf NPROCESSORS_ONLN' will succeed on GNU/Linux systems anyways; and the non-underscore-prefixed invocation works fine on all BSD flavors tested. Thus the `nproc' and `gnproc' attempts will never be reached. The only downside is we lose the ability to account for CPU affinity, but that's probably not an issue since CPU affinity (AFAIK) isn't a commonly-used feature.
-rw-r--r-- | Makefile.PL | 4 | ||||
-rwxr-xr-x | ci/run.sh | 2 | ||||
-rw-r--r-- | lib/PublicInbox/IPC.pm | 11 |
3 files changed, 7 insertions, 10 deletions
diff --git a/Makefile.PL b/Makefile.PL index 5b7914dc..97e00395 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -199,8 +199,8 @@ WriteMakefile( ); sub MY::postamble { - my $N = (`{ getconf _NPROCESSORS_ONLN || getconf NPROCESSORS_ONLN || - gnproc || nproc; } 2>/dev/null` || 1); + my $N = (`{ getconf _NPROCESSORS_ONLN || + getconf NPROCESSORS_ONLN; } 2>/dev/null` || 1); $N += 1; # account for sleeps in some tests (and makes an IV) <<EOF; PROVE = prove @@ -12,7 +12,7 @@ then $DO $MAKE clean >/dev/null fi NPROC=${NPROC-$({ getconf _NPROCESSORS_ONLN || getconf NPROCESSORS_ONLN || - gnproc || nproc || echo 2; } 2>/dev/null)} + echo 2; } 2>/dev/null)} TEST_JOBS=${TEST_JOBS-1} $PERL -w ci/profiles.perl | while read args diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm index 39021f42..fa084795 100644 --- a/lib/PublicInbox/IPC.pm +++ b/lib/PublicInbox/IPC.pm @@ -464,16 +464,13 @@ sub detect_nproc () { my $n = $NPROCESSORS_ONLN{$^O}; return POSIX::sysconf($n) if defined $n; - # getconf(1) is POSIX, but *NPROCESSORS* vars are not + # getconf(1) is POSIX, but *NPROCESSORS* vars are not even if + # glibc, {Free,Net,Open}BSD all support them. for (qw(_NPROCESSORS_ONLN NPROCESSORS_ONLN)) { `getconf $_ 2>/dev/null` =~ /^(\d+)$/ and return $1; } - for my $nproc (qw(nproc gnproc)) { # GNU coreutils nproc - `$nproc 2>/dev/null` =~ /^(\d+)$/ and return $1; - } - - # should we bother with `sysctl hw.ncpu`? Those only give - # us total processor count, not online processor count. + # note: GNU nproc(1) checks CPU affinity, which is nice but + # isn't remotely portable undef } |