From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 713621F47C; Fri, 27 Jan 2023 08:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1674807261; bh=0D/QvtGepIZl/UHZAgY4oYPchi6f+BwxOXk0jOHRgw8=; h=Date:From:To:Subject:References:In-Reply-To:From; b=lSqQm57Ibv3WKZYhgNlJchO+0AOH3BZl1HZQsP6O7I4frbS0/c3UNhs1TXocqzYsD FTxoFcxP41vSIY5jMt0YUF27TbIPrjpnFp6MZ1wktWKohVugfw1MdDryGeRUzxMNF8 mCz7xEVmf4DMUdcKKyrlQquIqtp/mfQWYpuwqYA8= Date: Fri, 27 Jan 2023 08:14:21 +0000 From: Eric Wong To: meta@public-inbox.org Subject: Re: [PATCH 1/2] git: use --batch-command in git 2.36+ to save processes Message-ID: <20230127081421.M411750@dcvr> References: <20230126093257.1058494-1-e@80x24.org> <20230126093257.1058494-2-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230126093257.1058494-2-e@80x24.org> List-Id: t/imapd.t on my slower 32-bit machine fails without the following fix. I guess prefetch wasn't being tested on my faster workstation? Also, the prior use of `print { $git->{out} }' is a potential (but unlikely) bug since commit d4ba8828ab23f278 (git: fix asynchronous batching for deep pipelines, 2023-01-04) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 1c77b4ce..a9db8ad7 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -239,6 +239,16 @@ sub cat_async_retry ($$) { cat_async_step($self, $inflight); # take one step } +# returns true if prefetch is successful +sub async_prefetch { + my ($self, $oid, $cb, $arg) = @_; + my $inflight = $self->{inflight} or return; + return if @$inflight; + substr($oid, 0, 0) = 'contents ' if $self->{-bc}; + write_all($self, $self->{out}, "$oid\n", \&cat_async_step, $inflight); + push(@$inflight, $oid, $cb, $arg); +} + sub cat_async_step ($$) { my ($self, $inflight) = @_; die 'BUG: inflight empty or odd' if scalar(@$inflight) < 3; diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index 1f86aad0..49a3c602 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -98,12 +98,8 @@ sub ibx_async_prefetch { $oid .= " $git->{git_dir}\n"; return $GCF2C->gcf2_async(\$oid, $cb, $arg); # true } - } elsif ($git->{async_cat} && (my $inflight = $git->{inflight})) { - if (!@$inflight) { - print { $git->{out} } $oid, "\n" or - $git->fail("write error: $!"); - return push(@$inflight, $oid, $cb, $arg); - } + } elsif ($git->{async_cat}) { + return $git->async_prefetch($oid, $cb, $arg); } undef; }