From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EA0CA1F44D for ; Mon, 8 Apr 2024 09:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1712569762; bh=3ZwZMCpBBnEBa8yNq/OdjyO2yF4S5VA7LIEJNDKm0Ww=; h=From:To:Subject:Date:From; b=P5855ZI96/eBBiYpcOi510CbIiChGpQGeS0jp7u2zPlwHmwNDC4EswXMAYiZsarY8 Tgz4k2gerNPz4g4j8GNCGAE9qJjGUXc9FT91uBxW4KaZoIAVBSlgLi/DQKMdE55p/I O/+WObZITHhFFnPh5hXS29xjvxTV9XMosBuAsy2g= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] www: speed up global manifest.js.gz w/ "all" extindex Date: Mon, 8 Apr 2024 09:49:21 +0000 Message-ID: <20240408094921.800292-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: By reducing internal event loop iterations, this brings 300+ inboxes down ~32ms to ~27ms. It should also be more consistent on servers with busy event loops since all the Xapian DB traffic happens at once, theoretically mproving cache utilization. --- lib/PublicInbox/ConfigIter.pm | 7 +++---- lib/PublicInbox/ManifestJsGz.pm | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/ConfigIter.pm b/lib/PublicInbox/ConfigIter.pm index 14fcef83..f9e3451a 100644 --- a/lib/PublicInbox/ConfigIter.pm +++ b/lib/PublicInbox/ConfigIter.pm @@ -1,12 +1,11 @@ -# Copyright (C) 2020-2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ # Intended for PublicInbox::DS::event_loop in read-only daemons # to avoid each_inbox() monopolizing the event loop when hundreds/thousands # of inboxes are in play. package PublicInbox::ConfigIter; -use strict; -use v5.10.1; +use v5.12; sub new { my ($class, $pi_cfg, $cb, @args) = @_; @@ -25,7 +24,7 @@ sub event_step { PublicInbox::DS::requeue($self) if defined($section); } -# for generic PSGI servers +# for generic PSGI servers, but also ManifestJsGz w/ ALL extindex sub each_section { my $self = shift; my ($pi_cfg, $i, $cb, @arg) = @$self; diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm index 1f739baa..be5d5f2a 100644 --- a/lib/PublicInbox/ManifestJsGz.pm +++ b/lib/PublicInbox/ManifestJsGz.pm @@ -82,8 +82,9 @@ sub response { $ctx->can('list_match_i'), $re, $ctx); sub { $ctx->{-wcb} = $_[0]; # HTTP server callback - $ctx->{env}->{'pi-httpd.async'} ? - $iter->event_step : $iter->each_section; + ($ctx->{www}->{pi_cfg}->ALL || + !$ctx->{env}->{'pi-httpd.async'}) ? + $iter->each_section : $iter->event_step; } }