From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20220808231648.1954885-2-e@80x24.org> (raw)
In-Reply-To: <20220808231648.1954885-1-e@80x24.org>
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);
next prev parent reply other threads:[~2022-08-08 23:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 23:16 [PATCH 0/4] imap: reduce impact of bot scanners Eric Wong
2022-08-08 23:16 ` Eric Wong [this message]
2022-08-08 23:16 ` [PATCH 2/4] imap: only give AUTH=ANONYMOUS clients prefetch Eric Wong
2022-08-08 23:16 ` [PATCH 3/4] imap: prioritize AUTH=ANONYMOUS clients Eric Wong
2022-08-08 23:16 ` [PATCH 4/4] README: recommend AUTH=ANONYMOUS on IMAP URLs Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220808231648.1954885-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).