* [PATCH] extmsg: rework partial MID matching to favor current inbox
@ 2018-03-19 7:51 Eric Wong (Contractor, The Linux Foundation)
0 siblings, 0 replies; only message in thread
From: Eric Wong (Contractor, The Linux Foundation) @ 2018-03-19 7:51 UTC (permalink / raw)
To: meta
The current inbox is more important for partial Message-ID
matching, so we try harder on that to fix common errors before
moving onto other inboxes. Then, prevent expensive scanning of
other inboxes by requiring a Message-ID length of at least 16
bytes.
Finally, we limit the overall partial responses to 200 when
scanning other inboxes to avoid excessive memory usage.
---
lib/PublicInbox/ExtMsg.pm | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index f3076a3..c71510f 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -84,17 +84,33 @@ sub ext_msg {
my $n_partial = 0;
my @partial;
- eval { require PublicInbox::Msgmap };
- my $have_mm = $@ ? 0 : 1;
- if ($have_mm) {
+ if (my $mm = $cur->mm) {
+ my $tmp_mid = $mid;
+ my $res = $mm->mid_prefixes($tmp_mid, 100);
+ if ($res && scalar(@$res)) {
+ $n_partial += scalar(@$res);
+ push @partial, [ $cur, $res ];
+ # fixup common errors:
+ } elsif ($tmp_mid =~ s,/[tTf],,) {
+ $res = $mm->mid_prefixes($tmp_mid, 100);
+ if ($res && scalar(@$res)) {
+ $n_partial += scalar(@$res);
+ push @partial, [ $cur, $res ];
+ }
+ }
+ }
+
+ # can't find a partial match in current inbox, try the others:
+ if (!$n_partial && length($mid) >= 16) {
my $tmp_mid = $mid;
again:
- unshift @ibx, $cur;
foreach my $ibx (@ibx) {
my $mm = $ibx->mm or next;
- if (my $res = $mm->mid_prefixes($tmp_mid)) {
+ my $res = $mm->mid_prefixes($tmp_mid, 100);
+ if ($res && scalar(@$res)) {
$n_partial += scalar(@$res);
push @partial, [ $ibx, $res ];
+ last if $n_partial >= 100;
}
}
# fixup common errors:
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-19 7:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19 7:51 [PATCH] extmsg: rework partial MID matching to favor current inbox Eric Wong (Contractor, The Linux Foundation)
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).