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-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,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 907781F9FF for ; Tue, 23 Feb 2021 10:01:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] lei q: reduce default lei2mail workers Date: Tue, 23 Feb 2021 04:01:15 -0600 Message-Id: <20210223100116.19927-3-e@80x24.org> In-Reply-To: <20210223100116.19927-1-e@80x24.org> References: <20210223100116.19927-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;