From e9cb3911178669cb16a65ab5741eea44b79fea03 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 10 Sep 2023 23:35:01 +0200 Subject: [PATCH] project: Optimise GetCommitRevisionId when revisionId is set When comparing 2 manifests, most of the time is spent getting the relevant commit id as it relies on _allrefs which ends up loading all git references. However, the value from `revisionIs` (when it is valid) could be used directly leading to a huge performance improvement (from 180+ seconds to less than 0.01 sec which is more than 25000 times faster for manifests with 700+ projects). Bug: 295282548 Change-Id: I5881aa4b2326cc17bbb4ee91d23293111f76ad7e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385834 Tested-by: Sylvain Desodt Reviewed-by: Mike Frysinger Commit-Queue: Sylvain Desodt --- project.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project.py b/project.py index 34e9046d..f2f81d7a 100644 --- a/project.py +++ b/project.py @@ -1443,6 +1443,8 @@ class Project(object): rather than the id of the current git object (for example, a tag) """ + if self.revisionId: + return self.revisionId if not self.revisionExpr.startswith(R_TAGS): return self.GetRevisionId(self._allrefs)