From 205599c0814e1031760e54cce9d8880e747cbb08 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 28 Sep 2021 07:53:49 +0000 Subject: www+httpd: lower priority of large mbox downloads While each git blob request is treated fairly w.r.t other git blob requests, responses triggering thousands of git blob requests can still noticeably increase latency for less-expensive responses. Move large mbox results and the nasty all.mbox endpoint to a low priority queue which only fires once per-event loop iteration. This reduces the response time of short HTTP responses while many gigantic mboxes are being downloaded simultaneously, but still maximizes use of available I/O when there's no inexpensive HTTP responses happening. This only affects PublicInbox::WWW users who use public-inbox-httpd, not generic PSGI servers. --- lib/PublicInbox/GzipFilter.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/GzipFilter.pm') diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm index 334d6581..c50c26c5 100644 --- a/lib/PublicInbox/GzipFilter.pm +++ b/lib/PublicInbox/GzipFilter.pm @@ -175,7 +175,12 @@ sub async_blob_cb { # git->cat_async callback $smsg->{blob} eq $oid or bail($self, "BUG: $smsg->{blob} != $oid"); eval { $self->async_eml(PublicInbox::Eml->new($bref)) }; bail($self, "E: async_eml: $@") if $@; - $http->next_step($self->can('async_next')); + if ($self->{-low_prio}) { + push(@{$self->{www}->{-low_prio_q}}, $self) == 1 and + PublicInbox::DS::requeue($self->{www}); + } else { + $http->next_step($self->can('async_next')); + } } sub smsg_blob { -- cgit v1.2.3-24-ge0c7