about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-23 04:01:15 -0600
committerEric Wong <e@80x24.org>2021-02-23 23:04:12 +0000
commitf75c6cf666fa202da782de43fd150bbeceb734e4 (patch)
tree3c56af0e2f49b749dfb9e9a520b9f7ffba769bcd
parent238422ea83adbe93145bbd18455ffffb84b53124 (diff)
downloadpublic-inbox-f75c6cf666fa202da782de43fd150bbeceb734e4.tar.gz
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.
-rw-r--r--lib/PublicInbox/LeiQuery.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 214267ee..743fa3f7 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -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;