From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/5] lei q: reduce lei/store work for kw changes to stored mail
Date: Thu, 1 Apr 2021 17:10:39 +0500 [thread overview]
Message-ID: <20210401121042.6456-3-e@80x24.org> (raw)
In-Reply-To: <20210401121042.6456-1-e@80x24.org>
We can tweak lse->kw_changed to return docids and reduce IPC
traffic and reduce work the lei/store worker needs to do.
---
lib/PublicInbox/LeiSearch.pm | 9 +++++----
lib/PublicInbox/LeiStore.pm | 8 ++++----
lib/PublicInbox/LeiToMail.pm | 6 +++---
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/PublicInbox/LeiSearch.pm b/lib/PublicInbox/LeiSearch.pm
index 07d570ec..69ba8303 100644
--- a/lib/PublicInbox/LeiSearch.pm
+++ b/lib/PublicInbox/LeiSearch.pm
@@ -100,10 +100,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) = @_;
- my $xoids = xoids_for($self, $eml, 1) // return;
- my ($num) = values %$xoids;
- my @cur_kw = msg_keywords($self, $num);
+ my ($self, $eml, $new_kw_sorted, $docids) = @_;
+ my $xoids = xoids_for($self, $eml) // return;
+ $docids //= [];
+ @$docids = sort { $a <=> $b } values %$xoids;
+ my @cur_kw = msg_keywords($self, $docids->[0]);
join("\0", @$new_kw_sorted) eq join("\0", @cur_kw) ? 0 : 1;
}
diff --git a/lib/PublicInbox/LeiStore.pm b/lib/PublicInbox/LeiStore.pm
index b76af4d3..48ab1d76 100644
--- a/lib/PublicInbox/LeiStore.pm
+++ b/lib/PublicInbox/LeiStore.pm
@@ -131,13 +131,13 @@ sub _docids_for ($$) {
}
sub set_eml_vmd {
- my ($self, $eml, $vmd) = @_;
+ my ($self, $eml, $vmd, $docids) = @_;
my $eidx = eidx_init($self);
- my @docids = _docids_for($self, $eml);
- for my $docid (@docids) {
+ $docids //= [ _docids_for($self, $eml) ];
+ for my $docid (@$docids) {
$eidx->idx_shard($docid)->ipc_do('set_vmd', $docid, $vmd);
}
- \@docids;
+ $docids;
}
sub add_eml_vmd {
diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm
index da633da4..0364d8ef 100644
--- a/lib/PublicInbox/LeiToMail.pm
+++ b/lib/PublicInbox/LeiToMail.pm
@@ -228,10 +228,10 @@ sub _mbox_write_cb ($$) {
sub update_kw_maybe ($$$$) {
my ($lei, $lse, $eml, $kw) = @_;
return unless $lse;
- my $lse_oids = $lse->kw_changed($eml, $kw);
+ my $c = $lse->kw_changed($eml, $kw, my $docids = []);
my $vmd = { kw => $kw };
- if ($lse_oids) { # already in lei/store
- $lei->{sto}->ipc_do('set_eml', $eml, $vmd);
+ if (scalar @$docids) { # already in lei/store
+ $lei->{sto}->ipc_do('set_eml_vmd', undef, $vmd, $docids) if $c;
} elsif (my $xoids = $lei->{ale}->xoids_for($eml)) {
# it's in an external, only set kw, here
$lei->{sto}->ipc_do('set_xvmd', $xoids, $eml, $vmd);
next prev parent reply other threads:[~2021-04-01 12:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 12:10 [PATCH 0/5] quieter and less noisy Eric Wong
2021-04-01 12:10 ` [PATCH 1/5] lei_query: remove unnecessary V2Writable require Eric Wong
2021-04-01 12:10 ` Eric Wong [this message]
2021-04-01 12:10 ` [PATCH 3/5] lei_store: set_xvmd: don't add if no vmd at all Eric Wong
2021-04-01 12:10 ` [PATCH 4/5] lei_store: quiet down git user info being unset Eric Wong
2021-04-01 12:10 ` [PATCH 5/5] lei_store: quiet down per-message related warnings 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=20210401121042.6456-3-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).