From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 663451FA19 for ; Sat, 7 Nov 2020 10:57:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 05/10] v2writable: less expensive checkpoint for extindex Date: Sat, 7 Nov 2020 10:56:55 +0000 Message-Id: <20201107105700.12586-6-e@80x24.org> In-Reply-To: <20201107105700.12586-1-e@80x24.org> References: <20201107105700.12586-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/V2Writable.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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}}));