diff options
author | Eric Wong <e@yhbt.net> | 2020-07-26 06:57:30 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-07-26 23:46:39 +0000 |
commit | 27277902f3ddb10af08c9870e3e9af1285e390ce (patch) | |
tree | 1d9f14ee7aa356962720df7d5a38a41f6fb7a1b4 /lib/PublicInbox/Git.pm | |
parent | 999e8c1b3d54f4504cd4fa87949a077da325a1af (diff) | |
download | public-inbox-27277902f3ddb10af08c9870e3e9af1285e390ce.tar.gz |
imap: introduce and use Git->async_prefetch
We can keep the git process more active by sending another request to it while fetch_run_ops() is running. This parallelization speeds up mutt's initial FETCH for headers by around ~35%(!).
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r-- | lib/PublicInbox/Git.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index ffc464eb..7b2ada24 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -410,6 +410,22 @@ sub cat_async ($$$;$) { push(@$inflight, $oid, $cb, $arg); } +# this is safe to call inside $cb, but not guaranteed to enqueue +# returns true if successful, undef if not. +sub async_prefetch { + my ($self, $oid, $cb, $arg) = @_; + if (defined($self->{async_cat}) && (my $inflight = $self->{inflight})) { + # we could use MAX_INFLIGHT here w/o the halving, + # but lets not allow one client to monopolize a git process + if (scalar(@$inflight) < int(MAX_INFLIGHT/2)) { + print { $self->{out} } $oid, "\n" or + fail($self, "write error: $!"); + return push(@$inflight, $oid, $cb, $arg); + } + } + undef; +} + sub extract_cmt_time { my ($bref, undef, undef, undef, $modified) = @_; |