user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei import: reduce writes to lei/store on IMAP sync
Date: Mon, 31 May 2021 10:20:06 +0000	[thread overview]
Message-ID: <20210531102006.3660-1-e@80x24.org> (raw)

We don't need to write VMD changes to lei/store if local
keywords are unchanged.
---
 lib/PublicInbox/LeiImport.pm | 1 +
 lib/PublicInbox/LeiSearch.pm | 8 +++++---
 lib/PublicInbox/NetReader.pm | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index f9a46ec5..860a2c98 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -50,6 +50,7 @@ sub input_net_cb { # imap_each / nntp_each
 	} elsif ($vmd) { # old message, kw only
 		my $oid = $self->{-lms_ro}->imap_oid2($uri, $uid) // return;
 		my @docids = $self->{lse}->over->blob_exists($oid) or return;
+		$self->{lse}->kw_changed(undef, $kw, \@docids) or return;
 		my $lei = $self->{lei};
 		$lei->qerr("# $oid => @$kw\n") if $lei->{opt}->{verbose};
 		$self->{lei}->{sto}->ipc_do('set_eml_vmd', undef,
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index b09d1e45..d0963e92 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -133,9 +133,11 @@ sub xoids_for {
 # returns true if $eml is indexed by lei/store and keywords don't match
 sub kw_changed {
 	my ($self, $eml, $new_kw_sorted, $docids) = @_;
-	my $xoids = xoids_for($self, $eml) // return;
-	$docids //= [];
-	@$docids = sort { $a <=> $b } values %$xoids;
+	if ($eml) {
+		my $xoids = xoids_for($self, $eml) // return;
+		$docids //= [];
+		@$docids = sort { $a <=> $b } values %$xoids;
+	}
 	my $cur_kw = msg_keywords($self, $docids->[0]);
 
 	# RFC 5550 sec 5.9 on the $Forwarded keyword states:
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index b97444fd..39a8f7fc 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -409,7 +409,7 @@ sub flags2kw ($$$$) {
 			warn "# unknown IMAP flag $f <$uri/;UID=$uid>\n";
 		}
 	}
-	@$kw = sort @$kw; # for all UI/UX purposes
+	@$kw = sort @$kw; # for LeiSearch->kw_changed and UI/UX purposes
 	$kw;
 }
 

                 reply	other threads:[~2021-05-31 10:20 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=20210531102006.3660-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).