diff options
author | Eric Wong <e@yhbt.net> | 2020-07-14 02:14:32 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-07-14 23:23:03 +0000 |
commit | f06e84220e5566e74c4af675a7afaf1636b024e4 (patch) | |
tree | 9ce2bb6cf147c24cb346ab3f36f53751863cec68 /lib/PublicInbox/Msgmap.pm | |
parent | 322a79a6421b5993775f63ea25294a97c5203ac0 (diff) | |
download | public-inbox-f06e84220e5566e74c4af675a7afaf1636b024e4.tar.gz |
over+msgmap: do not store filename after DBI->connect
SQLite already knows the filename internally, so avoid having it as a long-lived Perl SV to save some bytes when there's many inboxes and open DBs.
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r-- | lib/PublicInbox/Msgmap.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index e86fb854..38ec7858 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -229,9 +229,9 @@ sub mid_set { sub DESTROY { my ($self) = @_; - delete $self->{dbh}; - my $f = $self->{filename}; + my $dbh = $self->{dbh} or return; if (($self->{pid} // 0) == $$) { + my $f = $dbh->sqlite_db_filename; unlink $f or warn "failed to unlink $f: $!\n"; } } @@ -239,8 +239,9 @@ sub DESTROY { sub atfork_parent { my ($self) = @_; $self->{pid} or die "not a temporary clone\n"; - delete $self->{dbh} and die "tmp_clone dbh not prepared for parent"; - my $dbh = $self->{dbh} = PublicInbox::Over::dbh_new($self, 1); + my $dbh = $self->{dbh} and die "tmp_clone dbh not prepared for parent"; + $self->{filename} = $dbh->sqlite_db_filename; + $dbh = $self->{dbh} = PublicInbox::Over::dbh_new($self, 1); $dbh->do('PRAGMA synchronous = OFF'); } @@ -249,9 +250,10 @@ sub atfork_prepare { $self->{pid} or die "not a temporary clone\n"; $self->{pid} == $$ or die "BUG: atfork_prepare not called from $self->{pid}\n"; - $self->{dbh} or die "temporary clone not open\n"; + my $dbh = $self->{dbh} or die "temporary clone not open\n"; + # must clobber prepared statements - %$self = (filename => $self->{filename}, pid => $$); + %$self = (filename => $dbh->sqlite_db_filename, pid => $$); } sub skip_artnum { |