diff options
author | Eric Wong <e@80x24.org> | 2023-09-30 15:20:38 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-01 07:05:21 +0000 |
commit | bf929e8ddfb9359a97cd8be3d3017c038564d52d (patch) | |
tree | b9cbb8297be3610580607448c66c6a8b157c6e04 /lib/PublicInbox/Git.pm | |
parent | fc9f098c174a3e80dfe80567ee93c2bcb9e90266 (diff) | |
download | public-inbox-bf929e8ddfb9359a97cd8be3d3017c038564d52d.tar.gz |
While pipes guarantee writes of <= 512 bytes to be atomic, Unix stream sockets (or TCP sockets) have no such guarantees. Removing the pipe assumption will make it possible for us to switch to bidirectional Unix stream sockets and save FDs with `git cat-file' processes as we have with Gcf2Client. The performance benefit of larger pipe buffers over stream sockets isn't irrelevant when interacting with git as it is with SearchIdx shards.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r-- | lib/PublicInbox/Git.pm | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index eb88aa48..8ac40d2b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -223,25 +223,21 @@ sub my_readline ($$) { } sub cat_async_retry ($$) { - my ($self, $inflight) = @_; + my ($self, $old_inflight) = @_; # {inflight} may be non-existent, but if it isn't we delete it # here to prevent cleanup() from waiting: delete $self->{inflight}; cleanup($self); + batch_prepare($self, my $new_inflight = []); - batch_prepare($self, $inflight); - my $buf = ''; - for (my $i = 0; $i < @$inflight; $i += 3) { - $buf .= "$inflight->[$i]\n"; + while (my ($oid, $cb, $arg) = splice(@$old_inflight, 0, 3)) { + write_all($self, $self->{out}, $oid."\n", + \&cat_async_step, $new_inflight); + $oid = \$oid if !@$new_inflight; # to indicate oid retried + push @$new_inflight, $oid, $cb, $arg; } - $self->{out}->blocking(1); # brand new pipe, should never block - print { $self->{out} } $buf or $self->fail("write error: $!"); - $self->{out}->blocking(0); - my $req = shift @$inflight; - unshift(@$inflight, \$req); # \$ref to indicate retried - - cat_async_step($self, $inflight); # take one step + cat_async_step($self, $new_inflight); # take one step } # returns true if prefetch is successful |