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 29E621F677 for ; Sun, 26 Nov 2023 14:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1701008374; bh=hAcDuIHbQBdNwVhEaIJ3hYMo8ZXJScFY3lmGXVvr7lQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lKeupXJdNuzLAbJSdm/CSX6kyS/W9tOKEixkFZVmmc2tLvCTTFpAznZrx6PxgzmpC VWPLhWBOLhvZ2ti9sPbJ5HbhWdDd2I7JlP6DMws9NMdm6JHCy+QID4rQ62ybe+oJ3O WkQ6+Avj/00USNttwNGxOEUvqqXNM0wVsZI06JRE= From: Eric Wong To: spew@80x24.org Subject: [PATCH 6/7] git: speed up ->git_path for non-worktrees Date: Sun, 26 Nov 2023 14:19:32 +0000 Message-ID: <20231126141933.593525-6-e@80x24.org> In-Reply-To: <20231126141933.593525-1-e@80x24.org> References: <20231126141933.593525-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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index fe834210..6c7c11b6 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -99,15 +99,15 @@ sub new { sub git_path ($$) { my ($self, $path) = @_; - $self->{-git_path}->{$path} //= do { + $self->{-git_path}->{$path} // do { + return "$self->{git_dir}/$path" if -d $self->{git_dir}; + local $/ = "\n"; - chomp(my $str = $self->qx(qw(rev-parse --git-path), $path)); + chomp(my $s = $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"; - } - $str; + $self->{-git_path}->{$path} = $s eq "--git-path\n$path" ? + "$self->{git_dir}/$path" : $s; }; }