From: Eric Wong Date: Sat, 7 Nov 2020 10:56:55 +0000 (+0000) Subject: v2writable: less expensive checkpoint for extindex X-Git-Tag: v1.7.0~1643 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d463ecedb2030e53eb92befe8f642d9e244c9eae;p=public-inbox.git v2writable: less expensive checkpoint for extindex Since extindex holds no locks on parallel inbox writers, we can simply use "barrier" IPC shard commands to checkpoint and avoid respawning shard or git processes. --- diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 0364857f..224675ab 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -620,13 +620,13 @@ sub checkpoint ($;$) { # Now deal with Xapian if ($wait) { - my $barrier = $self->barrier_init(scalar @$shards); + my $barrier = barrier_init($self, scalar @$shards); # each shard needs to issue a barrier command $_->shard_barrier for @$shards; # wait for each Xapian shard - $self->barrier_wait($barrier); + barrier_wait($self, $barrier); } else { $_->shard_commit for @$shards; } @@ -860,11 +860,16 @@ sub atfork_child { sub reindex_checkpoint ($$) { my ($self, $sync) = @_; - $self->git->cleanup; # *async_wait + $self->git->async_wait_all; ${$sync->{need_checkpoint}} = 0; my $mm_tmp = $sync->{mm_tmp}; $mm_tmp->atfork_prepare if $mm_tmp; - $self->done; # release lock + die 'BUG: {im} during reindex' if $self->{im}; + if ($self->{ibx_map}) { + checkpoint($self, 1); # no need to release lock on pure index + } else { + $self->done; # release lock + } if (my $pr = $sync->{-opt}->{-progress}) { $pr->(sprintf($sync->{-regen_fmt}, ${$sync->{nr}}));