user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: "Eric Wong (Contractor, The Linux Foundation)" <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] extmsg: rework partial MID matching to favor current inbox
Date: Mon, 19 Mar 2018 07:51:09 +0000	[thread overview]
Message-ID: <20180319075109.6367-1-e@80x24.org> (raw)

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


                 reply	other threads:[~2018-03-19  7:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180319075109.6367-1-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).