From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EFAA01F9E5 for ; Tue, 20 Apr 2021 19:02:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] lei_query: avoid POSIX::lround for older Perls Date: Wed, 21 Apr 2021 00:02:06 +0500 Message-Id: <20210420190206.24183-3-e@80x24.org> In-Reply-To: <20210420174912.h6d2yv7zu5xr4yfc@nitro.local> References: <20210420174912.h6d2yv7zu5xr4yfc@nitro.local> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: POSIX.pm shipped with Perl 5.16.3 did not support lround, at least. So just rely on built-in core functions. --- lib/PublicInbox/LeiQuery.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm index 385ba0a9..f51dc93b 100644 --- a/lib/PublicInbox/LeiQuery.pm +++ b/lib/PublicInbox/LeiQuery.pm @@ -5,7 +5,6 @@ package PublicInbox::LeiQuery; use strict; use v5.10.1; -use POSIX (); sub prep_ext { # externals_each callback my ($lxs, $exclude, $loc) = @_; @@ -22,7 +21,7 @@ sub _start_query { # used by "lei q" and "lei up" } my $lxs = $self->{lxs}; $xj ||= $lxs->concurrency($opt); # allow: "--jobs ,$WRITER_ONLY" - my $nproc = $lxs->detect_nproc // 1; # don't memoize, schedtool(1) exists + my $nproc = $lxs->detect_nproc || 1; # don't memoize, schedtool(1) exists $xj = $nproc if $xj > $nproc; $lxs->{-wq_nr_workers} = $xj; if (defined($mj) && $mj !~ /\A[1-9][0-9]*\z/) { @@ -36,8 +35,7 @@ sub _start_query { # used by "lei q" and "lei up" $self->_lei_store(1)->write_prepare($self); } $l2m and $l2m->{-wq_nr_workers} = $mj // do { - $mj = POSIX::lround($nproc * 3 / 4); # keep some CPU for git - $mj <= 0 ? 1 : $mj; + $mj = int($nproc * 0.75 + 0.5); # keep some CPU for git }; # descending docid order is cheapest, MUA controls sorting order