From fffbc9ec32b78731acd30539f6e3f2778d2d1fb2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Jan 2019 02:10:13 +0000 Subject: solver: rewrite to use Qspawn->psgi_qx and pi-httpd.async The psgi_qx routine in the now-abandoned "repobrowse" branch allows us to break down blob-solving at each process execution point. It reuses the Qspawn facility for git-http-backend(1), allowing us to limit parallel subprocesses independently of Perl worker count. This is actually a 2-3% slower a fully-synchronous execution; but it is fair to other clients as it won't monopolize the server for hundreds of milliseconds (or even seconds) at a time. --- lib/PublicInbox/HTTPD/Async.pm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/PublicInbox/HTTPD') diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm index a1f75518..a647f10d 100644 --- a/lib/PublicInbox/HTTPD/Async.pm +++ b/lib/PublicInbox/HTTPD/Async.pm @@ -14,6 +14,15 @@ require PublicInbox::EvCleanup; sub new { my ($class, $io, $cb, $cleanup) = @_; + + # no $io? call $cb at the top of the next event loop to + # avoid recursion: + unless (defined($io)) { + PublicInbox::EvCleanup::asap($cb) if $cb; + PublicInbox::EvCleanup::next_tick($cleanup) if $cleanup; + return; + } + my $self = fields::new($class); IO::Handle::blocking($io, 0); $self->SUPER::new($io); -- cgit v1.2.3-24-ge0c7