about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-10 07:04:22 +0000
committerEric Wong <e@yhbt.net>2020-06-13 07:55:45 +0000
commiteeeae20893a2595631359e719eadac9686572734 (patch)
treec63dc3e396f16066db3e6366997fe11612676ad2 /lib/PublicInbox/Git.pm
parent6d2fad2c3f6eaf7334b1e805de607e1d5b24ff9e (diff)
downloadpublic-inbox-eeeae20893a2595631359e719eadac9686572734.tar.gz
This ought to improve overall performance with multiple clients.
Single client performance suffers a tiny bit due to extra
syscall overhead from epoll.

This also makes the existing async interface easier-to-use,
since calling cat_async_begin is no longer required.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 54c163e8..c5a3fa46 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -156,7 +156,7 @@ sub my_readline ($$) {
         }
 }
 
-sub _cat_async_step ($$) {
+sub cat_async_step ($$) {
         my ($self, $inflight) = @_;
         die 'BUG: inflight empty or odd' if scalar(@$inflight) < 2;
         my ($cb, $arg) = splice(@$inflight, 0, 2);
@@ -178,7 +178,7 @@ sub cat_async_wait ($) {
         my ($self) = @_;
         my $inflight = delete $self->{inflight} or return;
         while (scalar(@$inflight)) {
-                _cat_async_step($self, $inflight);
+                cat_async_step($self, $inflight);
         }
 }
 
@@ -277,6 +277,7 @@ sub qx {
 # returns true if there are pending "git cat-file" processes
 sub cleanup {
         my ($self) = @_;
+        cat_async_wait($self);
         _destroy($self, qw(--batch in out pid));
         _destroy($self, qw(--batch-check in_c out_c pid_c err_c));
         !!($self->{pid} || $self->{pid_c});
@@ -334,9 +335,9 @@ sub cat_async_begin {
 
 sub cat_async ($$$;$) {
         my ($self, $oid, $cb, $arg) = @_;
-        my $inflight = $self->{inflight} or die 'BUG: not in async';
+        my $inflight = $self->{inflight} // cat_async_begin($self);
         if (scalar(@$inflight) >= MAX_INFLIGHT) {
-                _cat_async_step($self, $inflight);
+                cat_async_step($self, $inflight);
         }
 
         print { $self->{out} } $oid, "\n" or fail($self, "write error: $!");
@@ -358,7 +359,6 @@ sub modified ($) {
         my ($self) = @_;
         my $modified = 0;
         my $fh = popen($self, qw(rev-parse --branches));
-        cat_async_begin($self);
         local $/ = "\n";
         while (my $oid = <$fh>) {
                 chomp $oid;