* [PATCH 6/9] inbox: inline and eliminate git_cleanup
2021-10-01 9:54 6% [PATCH 0/9] daemon-related things Eric Wong
@ 2021-10-01 9:54 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-01 9:54 UTC (permalink / raw)
To: meta
It was probably incorrect to use from max_git_epoch, and it's
small enough to inline into do_cleanup. We'll also eliminate
the unnecessary deletion of {-altid_map} while we're in the
area, since we no longer cache/memoize that.
Fixes: 7e5cea05f061e757 ("inbox: rewrite cleanup to be more aggressive")
---
lib/PublicInbox/Inbox.pm | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 95467d5ac54b..7c1c3afedf2d 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -10,31 +10,22 @@ use PublicInbox::Eml;
use List::Util qw(max);
use Carp qw(croak);
-sub git_cleanup ($) {
- my ($self) = @_;
- my $git = $self->{git} // return undef;
- # normal inboxes have low startup cost and there may be many, so
- # keep process+pipe counts in check. ExtSearch may have high startup
- # cost (e.g. ->ALL) and but likely one per-daemon, so cleanup only
- # if there's unlinked files
- my $live = $self->isa(__PACKAGE__) ? $git->cleanup(1)
- : $git->cleanup_if_unlinked;
- delete($self->{git}) unless $live;
- $live;
-}
-
# returns true if further checking is required
sub cleanup_shards { $_[0]->{search} ? $_[0]->{search}->cleanup_shards : undef }
sub do_cleanup {
my ($ibx) = @_;
- my $live = git_cleanup($ibx);
+ my $live;
+ if (defined $ibx->{git}) {
+ $live = $ibx->isa(__PACKAGE__) ? $ibx->{git}->cleanup(1)
+ : $ibx->{git}->cleanup_if_unlinked;
+ delete($ibx->{git}) unless $live;
+ }
$ibx->cleanup_shards and $live = 1;
for my $git (@{$ibx->{-repo_objs} // []}) {
$live = 1 if $git->cleanup(1);
}
- delete @$ibx{qw(over mm description cloneurl
- -altid_map -imap_url -nntp_url)};
+ delete(@$ibx{qw(over mm description cloneurl -imap_url -nntp_url)});
PublicInbox::DS::add_uniq_timer($ibx+0, 5, \&do_cleanup, $ibx) if $live;
}
@@ -126,7 +117,7 @@ sub max_git_epoch {
my $cur = $self->{-max_git_epoch};
my $changed;
if (!defined($cur) || ($changed = git($self)->alternates_changed)) {
- git_cleanup($self) if $changed;
+ $self->{git}->cleanup if $changed;
my $gits = "$self->{inboxdir}/git";
if (opendir my $dh, $gits) {
my $max = max(map {
^ permalink raw reply related [relevance 7%]
* [PATCH 0/9] daemon-related things
@ 2021-10-01 9:54 6% Eric Wong
2021-10-01 9:54 7% ` [PATCH 6/9] inbox: inline and eliminate git_cleanup Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-01 9:54 UTC (permalink / raw)
To: meta
5/9 has been a long-time coming, a few other small things, too.
The diff stat for lib/ alone shows a nice reduction
Eric Wong (9):
doc: lei-security: some more updates
listener: switch to level-triggered epoll
daemon: make SO_ACCEPTFILTER a shared variable
ipc: run Net::SSLeay::randomize
ds: simplify signalfd use
inbox: inline and eliminate git_cleanup
inbox: keep DB handles if git processes are live
ds: inline set_cloexec
doc: lei-daemon: new manpage
Documentation/lei-daemon.pod | 61 ++++++++++++++++
Documentation/lei-security.pod | 5 +-
Documentation/lei.pod | 9 ++-
Documentation/lei_design_notes.txt | 2 +-
MANIFEST | 1 +
Makefile.PL | 2 +-
lib/PublicInbox/ConfigIter.pm | 2 +-
lib/PublicInbox/DS.pm | 110 ++++++++++++++---------------
lib/PublicInbox/DSKQXS.pm | 10 +--
lib/PublicInbox/Daemon.pm | 20 ++----
lib/PublicInbox/ExtMsg.pm | 2 +-
lib/PublicInbox/ExtSearchIdx.pm | 12 +---
lib/PublicInbox/Gcf2Client.pm | 4 +-
lib/PublicInbox/Git.pm | 4 +-
lib/PublicInbox/IPC.pm | 5 +-
lib/PublicInbox/Inbox.pm | 41 +++++------
lib/PublicInbox/LEI.pm | 17 +----
lib/PublicInbox/Listener.pm | 5 +-
lib/PublicInbox/Qspawn.pm | 2 +-
lib/PublicInbox/Sigfd.pm | 10 +--
lib/PublicInbox/Syscall.pm | 12 ++--
lib/PublicInbox/Watch.pm | 3 +-
script/public-inbox-watch | 9 ---
t/dir_idle.t | 6 +-
t/ds-leak.t | 4 +-
t/httpd-corner.t | 4 +-
t/httpd-https.t | 6 +-
t/httpd.t | 6 +-
t/imapd-tls.t | 7 +-
t/imapd.t | 6 +-
t/nntpd-tls.t | 7 +-
t/nntpd.t | 2 +-
t/sigfd.t | 7 +-
t/watch_maildir.t | 2 +-
xt/mem-imapd-tls.t | 6 +-
xt/net_writer-imap.t | 2 +-
36 files changed, 221 insertions(+), 192 deletions(-)
create mode 100644 Documentation/lei-daemon.pod
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-01 9:54 6% [PATCH 0/9] daemon-related things Eric Wong
2021-10-01 9:54 7% ` [PATCH 6/9] inbox: inline and eliminate git_cleanup Eric Wong
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).