about summary refs log tree commit homepage
path: root/lib/PublicInbox/Mbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-09-28 07:53:49 +0000
committerEric Wong <e@80x24.org>2021-09-28 20:23:53 +0000
commit205599c0814e1031760e54cce9d8880e747cbb08 (patch)
tree5bda9afd681100d640288236e143e7ca215276b2 /lib/PublicInbox/Mbox.pm
parent3dbd6dc31dd7e34bea87dbb626f811e093b6860b (diff)
downloadpublic-inbox-205599c0814e1031760e54cce9d8880e747cbb08.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/Mbox.pm')
-rw-r--r--lib/PublicInbox/Mbox.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm
index f72af26b..cec76182 100644
--- a/lib/PublicInbox/Mbox.pm
+++ b/lib/PublicInbox/Mbox.pm
@@ -174,6 +174,7 @@ sub mbox_all_ids {
                 [404, [qw(Content-Type text/plain)], ["No results found\n"]];
         $ctx->{ids} = $ids;
         $ctx->{prev} = $prev;
+        $ctx->{-low_prio} = 1;
         require PublicInbox::MboxGz;
         PublicInbox::MboxGz::mbox_gz($ctx, \&all_ids_cb, 'all');
 }
@@ -192,12 +193,13 @@ sub results_cb {
                         my $smsg = $over->get_art($num) or next;
                         return $smsg;
                 }
-                # refill result set
+                # refill result set, deprioritize since there's many results
                 my $srch = $ctx->{ibx}->isrch or return gone($ctx, 'search');
                 my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
                 my $size = $mset->size or return;
                 $ctx->{qopts}->{offset} += $size;
                 $ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
+                $ctx->{-low_prio} = 1;
         }
 }
 
@@ -214,12 +216,13 @@ sub results_thread_cb {
                 # refills ctx->{xids}
                 next if $over->expand_thread($ctx);
 
-                # refill result set
+                # refill result set, deprioritize since there's many results
                 my $srch = $ctx->{ibx}->isrch or return gone($ctx, 'search');
                 my $mset = $srch->mset($ctx->{query}, $ctx->{qopts});
                 my $size = $mset->size or return;
                 $ctx->{qopts}->{offset} += $size;
                 $ctx->{ids} = $srch->mset_to_artnums($mset, $ctx->{qopts});
+                $ctx->{-low_prio} = 1;
         }
 
 }