about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTP.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-05 23:27:30 +0000
committerEric Wong <e@yhbt.net>2020-07-06 20:01:15 +0000
commitc86657e655936d59cab8a88ef1fc1e986c5fb3f0 (patch)
tree3fb85a047354a50827cc033f8fdc67da4fabf023 /lib/PublicInbox/HTTP.pm
parenta3f00c4a7851b98b81a2fcb31d5ed131908e22de (diff)
downloadpublic-inbox-c86657e655936d59cab8a88ef1fc1e986c5fb3f0.tar.gz
This lets the -httpd worker process make better use of time
instead of waiting for git-cat-file to respond.  With 4 jobs in
the new test case against a clone of
<https://public-inbox.org/meta/>, a speedup of 10-12% is shown.
Even a single job shows a 2-5% improvement on an SSD.
Diffstat (limited to 'lib/PublicInbox/HTTP.pm')
-rw-r--r--lib/PublicInbox/HTTP.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 82817465..5844ef44 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -488,6 +488,13 @@ sub busy () {
         ($self->{rbuf} || exists($self->{env}) || $self->{wbuf});
 }
 
+# runs $cb on the next iteration of the event loop at earliest
+sub next_step {
+        my ($self, $cb) = @_;
+        return unless exists $self->{sock};
+        $self->requeue if 1 == push(@{$self->{wbuf}}, $cb);
+}
+
 # Chunked and Identity packages are used for writing responses.
 # They may be exposed to the PSGI application when the PSGI app
 # returns a CODE ref for "push"-based responses