unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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	[thread overview]
Message-ID: <20210420190206.24183-3-e@80x24.org> (raw)
In-Reply-To: <20210420174912.h6d2yv7zu5xr4yfc@nitro.local>

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

      parent reply	other threads:[~2021-04-20 19:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20 17:49 c1b912dea25 breaks make test on CentOS7 Konstantin Ryabitsev
2021-04-20 19:02 ` [PATCH 0/2] CentOS 7 fixes Eric Wong
2021-04-20 19:17   ` Konstantin Ryabitsev
2021-04-20 19:02 ` [PATCH 1/2] test_common: fix xbail for Perl 5.16 Eric Wong
2021-04-20 19:02 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210420190206.24183-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).