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 60DBE1F68D for ; Tue, 28 Nov 2023 14:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1701183389; bh=qOnAdV/IGmHnSkGvndkmRgC61HysWu/zC2rF2hziNYU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=0p3ZvSxFqz/Bsd754iyDsUIEKcz4z6REl2EKVm39pA1gSF0HDhWy7/Eg0AE/HTJD4 PVbqagEfiUbYGnmEuUkzJJx8pf9QguIBnINdKM1++3zHMApd85MWTEgL7QNulspfZo Y0rgLDNRtHM38WMmxnUJ/tEzvh6W/Yo1zcuwjhUg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 09/14] git: speed up ->git_path for non-worktrees Date: Tue, 28 Nov 2023 14:56:22 +0000 Message-ID: <20231128145628.1455176-10-e@80x24.org> In-Reply-To: <20231128145628.1455176-1-e@80x24.org> References: <20231128145628.1455176-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Only worktrees need to use `git rev-parse --git-path', so avoid the spawn overhead of a new process. With the SolverGit.pm limit on coderepo scans disabled and scanning over 800 git repos for git@vger matches, this reduces up xt/solver.t times by roughly 25%. --- lib/PublicInbox/Git.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 7c6e15b7..a374649f 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -100,14 +100,17 @@ sub new { sub git_path ($$) { my ($self, $path) = @_; $self->{-git_path}->{$path} //= do { - local $/ = "\n"; - chomp(my $str = $self->qx(qw(rev-parse --git-path), $path)); - - # git prior to 2.5.0 did not understand --git-path - if ($str eq "--git-path\n$path") { - $str = "$self->{git_dir}/$path"; + my $d = "$self->{git_dir}/$path"; + if (-e $d) { + $d; + } else { + local $/ = "\n"; + my $s = $self->qx(qw(rev-parse --git-path), $path); + chomp $s; + + # git prior to 2.5.0 did not understand --git-path + $s eq "--git-path\n$path" ? $d : $s; } - $str; }; }