No need to fork a process on platforms I use daily, at least.
use PublicInbox::SearchIdx qw(log2stack is_ancestor check_size is_bad_blob);
use IO::Handle; # ->autoflush
use File::Temp ();
use PublicInbox::SearchIdx qw(log2stack is_ancestor check_size is_bad_blob);
use IO::Handle; # ->autoflush
use File::Temp ();
my $OID = qr/[a-f0-9]{40,}/;
# an estimate of the post-packed size to the raw uncompressed size
my $OID = qr/[a-f0-9]{40,}/;
# an estimate of the post-packed size to the raw uncompressed size
our $NPROC_MAX_DEFAULT = 4;
sub detect_nproc () {
our $NPROC_MAX_DEFAULT = 4;
sub detect_nproc () {
+ # _SC_NPROCESSORS_ONLN = 84 on both Linux glibc and musl
+ return POSIX::sysconf(84) if $^O eq 'linux';
+ return POSIX::sysconf(58) if $^O eq 'freebsd';
+ # TODO: more OSes
+
# getconf(1) is POSIX, but *NPROCESSORS* vars are not
for (qw(_NPROCESSORS_ONLN NPROCESSORS_ONLN)) {
`getconf $_ 2>/dev/null` =~ /^(\d+)$/ and return $1;
# getconf(1) is POSIX, but *NPROCESSORS* vars are not
for (qw(_NPROCESSORS_ONLN NPROCESSORS_ONLN)) {
`getconf $_ 2>/dev/null` =~ /^(\d+)$/ and return $1;