unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: Re: [PATCH 1/2] git: use --batch-command in git 2.36+ to save processes
Date: Fri, 27 Jan 2023 08:14:21 +0000	[thread overview]
Message-ID: <20230127081421.M411750@dcvr> (raw)
In-Reply-To: <20230126093257.1058494-2-e@80x24.org>

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;
 }

  reply	other threads:[~2023-01-27  8:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  9:32 [PATCH 0/2] use `git cat-file --batch-command' if available Eric Wong
2023-01-26  9:32 ` [PATCH 1/2] git: use --batch-command in git 2.36+ to save processes Eric Wong
2023-01-27  8:14   ` Eric Wong [this message]
2023-01-27  8:17     ` Eric Wong
2023-02-09  1:29   ` Eric Wong
2023-02-20  8:19     ` [PATCH] git_async_cat: don't mis-abort replaced process Eric Wong
2023-01-26  9:32 ` [PATCH 2/2] git: drop needless checks for old git Eric Wong

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=20230127081421.M411750@dcvr \
    --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).