From 356439a571c536eaa487031802b436d087113f4f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 22 Sep 2021 09:45:17 +0000 Subject: gcf2 + extsearch: check for unlinked files on Linux Check for unlinked mmap-ed files via /proc/$PID/maps every 60s or so. ExtSearch (extindex) is compatible-enough with Inbox objects to be wired into the old per-inbox code, but the startup cost is projected to be much higher down the line when there's >30K inboxes, so we scan /proc/$PID/maps for deleted files before unlinking. With old Inbox objects, it was (and is) simpler to just kill processes w/o checking due to the low startup cost (and non-portability of checking). Reported-by: Konstantin Ryabitsev Link: https://public-inbox.org/meta/20210921144754.gulkneuulzo27qbw@meerkat.local/ --- lib/PublicInbox/Inbox.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Inbox.pm') diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 20f8c884..02ffc7be 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -22,8 +22,15 @@ my $CLEANUP = {}; # string(inbox) -> inbox sub git_cleanup ($) { my ($self) = @_; - my $git = $self->{git} or return; - $git->cleanup; + if ($self->isa(__PACKAGE__)) { + # normal Inbox; low startup cost, and likely to have many + # many so this keeps process/pipe counts in check + $self->{git}->cleanup if $self->{git}; + } else { + # ExtSearch, high startup cost if ->ALL, and probably + # only one per-daemon, so teardown only if required: + $self->git->cleanup_if_unlinked; + } } sub cleanup_task () { -- cgit v1.2.3-24-ge0c7