From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/3] searchidx: update_checkpoint: take bytes arg directly
Date: Thu, 12 Dec 2024 10:10:38 +0000 [thread overview]
Message-ID: <20241212101040.1109774-2-e@80x24.org> (raw)
In-Reply-To: <20241212101040.1109774-1-e@80x24.org>
Passing $smsg limits flexibility in case we reuse it for deletes
and/or commit search.
---
lib/PublicInbox/ExtSearchIdx.pm | 2 +-
lib/PublicInbox/SearchIdx.pm | 6 +++---
lib/PublicInbox/V2Writable.pm | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index fe2f5d2e..1c2a9a26 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -125,7 +125,7 @@ sub attach_config {
sub check_batch_limit ($) {
my ($req) = @_;
# set flag for PublicInbox::V2Writable::index_todo:
- update_checkpoint $req->{self}, $req->{new_smsg} and
+ update_checkpoint $req->{self}, $req->{new_smsg}->{bytes} and
${$req->{need_checkpoint}} = 1;
}
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 3a85f552..0d9acd20 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -788,8 +788,8 @@ sub is_bad_blob ($$$$) {
}
sub update_checkpoint ($$) {
- my ($self, $smsg) = @_;
- ($self->{transact_bytes} += $smsg->{bytes}) >= $self->{batch_bytes} and
+ my ($self, $bytes) = @_;
+ ($self->{transact_bytes} += $bytes) >= $self->{batch_bytes} and
return 1;
my $now = now;
my $next = $self->{next_checkpoint} //= $now + $CHECKPOINT_INTVL;
@@ -803,7 +803,7 @@ sub index_both { # git->cat_async callback
my $smsg = bless { blob => $oid }, 'PublicInbox::Smsg';
$smsg->set_bytes($$bref, $size);
my $self = $sync->{sidx};
- ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg;
+ ${$sync->{need_checkpoint}} = 1 if update_checkpoint $self, $smsg->{bytes};
local $self->{current_info} = "$self->{current_info}: $oid";
my $eml = PublicInbox::Eml->new($bref);
$smsg->{num} = index_mm($self, $eml, $oid, $sync) or
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 5f3bfde5..c894b648 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -107,7 +107,7 @@ sub do_idx ($$$) {
my $idx = idx_shard($self, $smsg->{num});
$idx->index_eml($eml, $smsg);
}
- update_checkpoint $self, $smsg;
+ update_checkpoint $self, $smsg->{bytes};
}
# returns undef on duplicate or spam
next prev parent reply other threads:[~2024-12-12 10:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 10:10 [PATCH 0/3] indexing cleanups Eric Wong
2024-12-12 10:10 ` Eric Wong [this message]
2024-12-12 10:10 ` [PATCH 2/3] extindex: move {checkpoint_unlocks} to $self Eric Wong
2024-12-12 10:10 ` [PATCH 3/3] searchidx: consolidate checkpoint accounting 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=20241212101040.1109774-2-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.
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).