From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei: quiet excessive write/seen messages
Date: Thu, 12 Oct 2023 00:21:00 +0000 [thread overview]
Message-ID: <20231012002100.220022-1-e@80x24.org> (raw)
We don't want to end up dumping nr_seen/nr_write when progress
is disabled, nor do we want forked off `lei note-event' workers
dump them when DS->Reset is called on fork.
---
lib/PublicInbox/LEI.pm | 11 +++++++----
lib/PublicInbox/LeiXSearch.pm | 6 +++---
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index af39f8af..b00be1a1 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -631,6 +631,7 @@ sub pkt_op_pair {
sub incr {
my $lei = shift;
+ $lei->{incr_pid} = $$ if @_;
while (my ($f, $n) = splice(@_, 0, 2)) { $lei->{$f} += $n }
}
@@ -1399,10 +1400,12 @@ sub busy { 1 } # prevent daemon-shutdown if client is connected
# can immediately reread it
sub DESTROY {
my ($self) = @_;
- for my $k (sort(grep(/\A-nr_/, keys %$self))) {
- my $nr = $self->{$k};
- substr($k, 0, length('-nr_'), '');
- $self->child_error(0, "$nr $k messages");
+ if (defined($self->{incr_pid}) && $self->{incr_pid} == $$) {
+ for my $k (sort(grep(/\A-nr_/, keys %$self))) {
+ my $nr = $self->{$k};
+ substr($k, 0, length('-nr_'), '');
+ $self->child_error(0, "$nr $k messages");
+ }
}
$self->{1}->autoflush(1) if $self->{1};
stop_pager($self);
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 2a4af3e7..d83a403c 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -419,12 +419,12 @@ Error closing $lei->{ovv}->{dst}: \$!=$! \$?=$?
delete $l2m->{mbl}; # drop dotlock
}
}
+ my $nr_w = delete($lei->{-nr_write}) // 0;
+ my $nr_dup = (delete($lei->{-nr_seen}) // 0) - $nr_w;
if ($lei->{-progress}) {
my $tot = $lei->{-mset_total} // 0;
- my $nr_w = delete($lei->{-nr_write}) // 0;
- my $d = (delete($lei->{-nr_seen}) // 0) - $nr_w;
my $x = "$tot matches";
- $x .= ", $d duplicates" if $d;
+ $x .= ", $nr_dup duplicates" if $nr_dup;
if ($l2m) {
my $m = "# $nr_w written to " .
"$lei->{ovv}->{dst} ($x)";
reply other threads:[~2023-10-12 0:21 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=20231012002100.220022-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.
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).