From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BA2921F59D for ; Mon, 8 Aug 2022 23:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1660000608; bh=AWFl4VAoI8fb8osGvJHydw4qmg8JD2/qaZAAO4KTzB4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qB6PPNte8JBvZQUhSiuvmcNEQXtqMzWA7qCvAzVk2LlgcYmKJLyVuTYbhaJJmq6zj MGFRhIvC2PBhWBkjlp9zVRMYvfpQHVvTlLHhUlDbKhyBWFAR7v/34cCF0j57oeAuGN koPhFxsHoLIMNzDZA3I/vKlBq8HCFafNKpPUInNI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/4] imap: limit ibx_async_prefetch to idle git processes Date: Mon, 8 Aug 2022 23:16:45 +0000 Message-Id: <20220808231648.1954885-2-e@80x24.org> In-Reply-To: <20220808231648.1954885-1-e@80x24.org> References: <20220808231648.1954885-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This improves fairness while having no measurable performance impact for a single uncached IMAP client (mutt) opening a folder for the first time. I noticed this problem with the public-inbox.org IMAP server where a few IMAP clients were unfairly monopolizing the -netd process. --- lib/PublicInbox/GitAsyncCat.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index cea3f539..6b7425f6 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -69,19 +69,18 @@ sub ibx_async_cat ($$$$) { } # this is safe to call inside $cb, but not guaranteed to enqueue -# returns true if successful, undef if not. +# returns true if successful, undef if not. For fairness, we only +# prefetch if there's no in-flight requests. sub ibx_async_prefetch { my ($ibx, $oid, $cb, $arg) = @_; my $git = $ibx->git; if (!defined($ibx->{topdir}) && $GCF2C) { - if (!$GCF2C->{wbuf}) { + if (!@{$GCF2C->{inflight} // []}) { $oid .= " $git->{git_dir}\n"; return $GCF2C->gcf2_async(\$oid, $cb, $arg); # true } } elsif ($git->{async_cat} && (my $inflight = $git->{inflight})) { - # we could use MAX_INFLIGHT here w/o the halving, - # but lets not allow one client to monopolize a git process - if (@$inflight < int(PublicInbox::Git::MAX_INFLIGHT/2)) { + if (!@$inflight) { print { $git->{out} } $oid, "\n" or $git->fail("write error: $!"); return push(@$inflight, $oid, $cb, $arg);