From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 11/9] inbox: reinstate periodic cleanup of Xapian and SQLite objects
Date: Wed, 11 Jan 2017 10:21:04 +0000 [thread overview]
Message-ID: <20170111102104.GA12206@dcvr> (raw)
In-Reply-To: <20170107014452.9657-6-e@80x24.org>
We may need to do this even more aggressively, since the
Xapian database does not always give the latest results.
This time, we'll do it without relying on weak references,
and instead check refcounts.
---
lib/PublicInbox/Inbox.pm | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 51ada0b..a0d69f1 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -7,6 +7,7 @@ use strict;
use warnings;
use PublicInbox::Git;
use PublicInbox::MID qw(mid2path);
+use Devel::Peek qw(SvREFCNT);
my $cleanup_timer;
eval {
@@ -18,10 +19,20 @@ eval {
my $CLEANUP = {}; # string(inbox) -> inbox
sub cleanup_task () {
$cleanup_timer = undef;
- delete $_->{git} for values %$CLEANUP;
+ for my $ibx (values %$CLEANUP) {
+ foreach my $f (qw(git mm search)) {
+ delete $ibx->{$f} if SvREFCNT($ibx->{$f}) == 1;
+ }
+ }
$CLEANUP = {};
}
+sub _cleanup_later ($) {
+ my ($self) = @_;
+ $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
+ $CLEANUP->{"$self"} = $self;
+}
+
sub _set_uint ($$$) {
my ($opts, $field, $default) = @_;
my $val = $opts->{$field};
@@ -70,20 +81,23 @@ sub git {
$self->{git} ||= eval {
my $g = PublicInbox::Git->new($self->{mainrepo});
$g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
- $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
- $CLEANUP->{"$self"} = $self;
+ _cleanup_later($self);
$g;
};
}
sub mm {
my ($self) = @_;
- $self->{mm} ||= eval { PublicInbox::Msgmap->new($self->{mainrepo}) };
+ $self->{mm} ||= eval {
+ _cleanup_later($self);
+ PublicInbox::Msgmap->new($self->{mainrepo});
+ };
}
sub search {
my ($self) = @_;
$self->{search} ||= eval {
+ _cleanup_later($self);
PublicInbox::Search->new($self->{mainrepo}, $self->{altid});
};
}
--
EW
next prev parent reply other threads:[~2017-01-11 10:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-07 1:44 [PATCH 0/9] misc cleanups and trimming Eric Wong
2017-01-07 1:44 ` [PATCH 1/9] qspawn: prepare to support runtime reloading of Limiter Eric Wong
2017-01-07 1:44 ` [PATCH 2/9] config: always use namespaced "publicinboxlimiter" Eric Wong
2017-01-07 1:44 ` [PATCH 3/9] config: remove unused get() method Eric Wong
2017-01-07 1:44 ` [PATCH 4/9] inbox: describe the full key name Eric Wong
2017-01-07 1:44 ` [PATCH 5/9] inbox: eliminate weaken usage entirely Eric Wong
2017-01-07 2:12 ` [PATCH 10/9] inbox: properly register cleanup timer for git processes Eric Wong
2017-01-11 10:21 ` Eric Wong [this message]
2017-01-07 1:44 ` [PATCH 6/9] config: allow per-inbox nntpserver Eric Wong
2017-01-07 1:44 ` [PATCH 7/9] remove incorrect comment about strftime + locales Eric Wong
2017-01-07 1:44 ` [PATCH 8/9] searchmsg: favor direct hash access over accessor methods Eric Wong
2017-01-07 1:44 ` [PATCH 9/9] search: remove subject_summary 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=20170111102104.GA12206@dcvr \
--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).