about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.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/Inbox.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/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index b250bef3..407751c3 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -18,6 +18,16 @@ my $cleanup_timer;
 my $cleanup_avail = -1; # 0, or 1
 my $have_devel_peek;
 my $CLEANUP = {}; # string(inbox) -> inbox
+
+sub git_cleanup ($) {
+        my ($self) = @_;
+        my $git = $self->{git} or return;
+        if (my $async_cat = delete $self->{async_cat}) {
+                $async_cat->close;
+        }
+        $git->cleanup;
+}
+
 sub cleanup_task () {
         $cleanup_timer = undef;
         my $next = {};
@@ -32,9 +42,7 @@ sub cleanup_task () {
                                 # refcnt is zero when tmp is out-of-scope
                         }
                 }
-                if (my $git = $ibx->{git}) {
-                        $again = $git->cleanup;
-                }
+                git_cleanup($ibx);
                 if (my $gits = $ibx->{-repo_objs}) {
                         foreach my $git (@$gits) {
                                 $again = 1 if $git->cleanup;
@@ -157,7 +165,7 @@ sub max_git_epoch {
         my $cur = $self->{-max_git_epoch};
         my $changed = git($self)->alternates_changed;
         if (!defined($cur) || $changed) {
-                $self->git->cleanup if $changed;
+                git_cleanup($self) if $changed;
                 my $gits = "$self->{inboxdir}/git";
                 if (opendir my $dh, $gits) {
                         my $max = -1;