]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
drop GNU nproc(1) support in favor of getconf(1)
authorEric Wong <e@80x24.org>
Mon, 18 Sep 2023 10:15:10 +0000 (10:15 +0000)
committerEric Wong <e@80x24.org>
Wed, 20 Sep 2023 19:14:19 +0000 (19:14 +0000)
`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.

Makefile.PL
ci/run.sh
lib/PublicInbox/IPC.pm

index 5b7914dc50cc9863a3345de0a4e53029033a4077..97e00395e55bf6d3146cf7919bcb5c9a73cbda9e 100644 (file)
@@ -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
index 93790269f1937036a35ef8e6fa978c27938cd1ba..bd1d8a4d65330ad2793a5992d303ec72992eceab 100755 (executable)
--- a/ci/run.sh
+++ b/ci/run.sh
@@ -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
index 39021f4253d3260df56ed4afb6ff993e8a86f590..fa08479500ccea07629f949c81d195c374aefb89 100644 (file)
@@ -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
 }