diff options
author | Eric Wong <e@80x24.org> | 2021-01-27 03:42:29 -0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-29 05:04:40 +0000 |
commit | 813d87c0ad24e1ea1d28a4b1570e5c57327b3c37 (patch) | |
tree | a902d08f26b20ce543d1f5f1ebcb7878491aead9 /lib/PublicInbox/V2Writable.pm | |
parent | 49385e3e730339d1dc86c6d37350518397ee6094 (diff) | |
download | public-inbox-813d87c0ad24e1ea1d28a4b1570e5c57327b3c37.tar.gz |
No need to fork a process on platforms I use daily, at least.
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r-- | lib/PublicInbox/V2Writable.pm | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 7f9342b0..35b7fe30 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -21,6 +21,7 @@ use PublicInbox::Search; use PublicInbox::SearchIdx qw(log2stack is_ancestor check_size is_bad_blob); use IO::Handle; # ->autoflush use File::Temp (); +use POSIX (); my $OID = qr/[a-f0-9]{40,}/; # an estimate of the post-packed size to the raw uncompressed size @@ -35,6 +36,11 @@ our $PACKING_FACTOR = 0.4; 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; |