From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3E94D1F461 for ; Wed, 6 Dec 2023 21:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1701897146; bh=gip24VC32AYk/fJIhzIJnomTfOYooQwGlhRBdsOlhLw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=O08KUspiqELUKDAUzU/rkukfgR7RGRXteu9Euy9L56tS88owO7MpwTAUY5nLiM4EX iCtuxIlR2ONeVKj8f0X8knTapuw17kmt39uLcpB/0pXTiKIWVstr0SzdZhV/qtrwbO bC2TXfI/WoQJF7qXXxgslYUFbXrxOg1XpfbssElI= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] cindex: avoid recursion on prune Date: Wed, 6 Dec 2023 21:12:25 +0000 Message-Id: <20231206211225.2952183-3-e@80x24.org> In-Reply-To: <20231206211225.2952183-1-e@80x24.org> References: <20231206211225.2952183-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There's no need to recurse and trigger deep recursion warnings when we hit a coderepo with a known hash (SHA-1 vs SHA-256). Noticed while pruning the 1200+ repos on a git.kernel.org mirror. --- lib/PublicInbox/CodeSearchIdx.pm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm index 20aac584..967933f2 100644 --- a/lib/PublicInbox/CodeSearchIdx.pm +++ b/lib/PublicInbox/CodeSearchIdx.pm @@ -909,21 +909,23 @@ sub prep_alternate_read { # run_git cb for config extensions.objectFormat sub prep_alternate_start { my ($self, $git, $run_prune) = @_; - my $o = $git->git_path('objects'); + local $self->{xdb}; + my ($o, $n, @ids, @fmt); +start: + $o = $git->git_path('objects'); while (!-d $o) { $git = shift(@PRUNEQ) // return; $o = $git->git_path('objects'); } - my $n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB); - local $self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]"); - my @ids = $self->docids_by_postlist('P'.$git->{git_dir}); - my @fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : (); + $n = git_dir_hash($git->{git_dir}) % scalar(@RDONLY_XDB); + $self->{xdb} = $RDONLY_XDB[$n] // croak("BUG: no shard[$n]"); + @ids = $self->docids_by_postlist('P'.$git->{git_dir}); + @fmt = @ids ? xap_terms('H', $self->{xdb}, $ids[0]) : (); @fmt > 1 and warn "BUG? multi `H' for shard[$n] #$ids[0]: @fmt"; if (@fmt) { # cache hit - @PRUNEQ and - prep_alternate_start($self, shift(@PRUNEQ), $run_prune); prep_alternate_end $o, $fmt[0]; + $git = shift(@PRUNEQ) and goto start; } else { # compatibility w/ early cidx format run_git([qw(config extensions.objectFormat)], { quiet => 1 }, \&prep_alternate_read, $self, $git, $o, $ids[0], $n,