]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei q: reduce default lei2mail workers
authorEric Wong <e@80x24.org>
Tue, 23 Feb 2021 10:01:15 +0000 (04:01 -0600)
committerEric Wong <e@80x24.org>
Tue, 23 Feb 2021 23:04:12 +0000 (23:04 +0000)
While disk I/O is typically buffered for good scheduling,
git blob decoding uses a non-trivial amount of CPU time
and it helps to leave some CPU available for it.

lib/PublicInbox/LeiQuery.pm

index 214267ee76ca87ebad553afc09724dd25ed170f8..743fa3f7b23600874f008ffdc9833273515529e9 100644 (file)
@@ -5,6 +5,7 @@
 package PublicInbox::LeiQuery;
 use strict;
 use v5.10.1;
+use POSIX ();
 
 sub prep_ext { # externals_each callback
        my ($lxs, $exclude, $loc) = @_;
@@ -94,7 +95,10 @@ sub lei_q {
                return $self->fail("`$mj' writer jobs must be >= 1");
        }
        PublicInbox::LeiOverview->new($self) or return;
-       $self->{l2m}->{-wq_nr_workers} = ($mj // $nproc) if $self->{l2m};
+       $self->{l2m} and $self->{l2m}->{-wq_nr_workers} = $mj // do {
+               $mj = POSIX::lround($nproc * 3 / 4); # keep some CPU for git
+               $mj <= 0 ? 1 : $mj;
+       };
 
        my %mset_opt = map { $_ => $opt->{$_} } qw(threads limit offset);
        $mset_opt{asc} = $opt->{'reverse'} ? 1 : 0;