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 D95AD1F8DF for ; Fri, 24 Jul 2020 05:56:07 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/20] v2writable: index_sync: reduce fill_alternates calls Date: Fri, 24 Jul 2020 05:55:50 +0000 Message-Id: <20200724055606.27332-5-e@yhbt.net> In-Reply-To: <20200724055606.27332-1-e@yhbt.net> References: <20200724055606.27332-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Instead of doing fill_alternates for every epoch we're indexing, just do it once at the start of index_sync invocation. This will set us up for using a single "git cat-file" process for indexing multiple epochs. --- lib/PublicInbox/V2Writable.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 04c91e5dd..c896dc0ed 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -682,10 +682,7 @@ sub fill_alternates ($$) { my $pfx = "$self->{-inbox}->{inboxdir}/git"; my $all = "$self->{-inbox}->{inboxdir}/all.git"; - - unless (-d $all) { - PublicInbox::Import::init_bare($all); - } + PublicInbox::Import::init_bare($all) unless -d $all; my $info_dir = "$all/objects/info"; my $alt = "$info_dir/alternates"; my (%alt, $new); @@ -695,7 +692,9 @@ sub fill_alternates ($$) { $mode = (stat($fh))[2] & 07777; # we assign a sort score to every alternate and favor - # the newest (highest numbered) one when we + # the newest (highest numbered) one because loose objects + # require scanning epochs and only the latest epoch is + # expected to see loose objects my $score; my $other = 0; # in case admin adds non-epoch repos %alt = map {; @@ -1213,7 +1212,6 @@ sub index_epoch ($$$) { my $git_dir = git_dir_n($self, $i); die 'BUG: already reindexing!' if $self->{reindex_pipe}; -d $git_dir or return; # missing epochs are fine - fill_alternates($self, $i); my $git = PublicInbox::Git->new($git_dir); if (my $unindex_range = delete $sync->{unindex_range}->{$i}) { unindex($self, $sync, $git, $unindex_range); @@ -1247,6 +1245,7 @@ sub index_sync { my $latest = git_dir_latest($self, \$epoch_max); return unless defined $latest; $self->idx_init($opt); # acquire lock + fill_alternates($self, $epoch_max); $self->{over}->rethread_prepare($opt); my $sync = { unindex_range => {}, # EPOCH => oid_old..oid_new