Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-45447] Improve poll and checkout performance for repos with …
…many tags

JENKINS-45447 reports that checkout of a repository with many tags
from a freestyle job using a wildcard in the branch name is
dramatically slower than earlier releases.  Many other cases which use
the advanced branch selection mechanism show the same performance
problem.

31fedce added tag checks to the evaluation loop for branch
names. Unfortunately, tag evaluation needs both the tag name and the
SHA1 of the commit identified by the tag. The original; implementation
called revParse() to compute that SHA1 for each tag. With many tags in
the repository (bug report example was 60,000 tags), the checkout time
increased dramatically.

I found that even the number of tags in the git plugin repository
could add as much as 5 seconds for the computation of SHA1 hashes.
Those computed SHA1 hashes were then immediately discarded because
they did not satisfy the branch name selection criteria.

Calling GitClient.getTags() returns more information than
GitClient.getTagNames(), so it is possible that this change is still
not fast enough.
  • Loading branch information
MarkEWaite committed Dec 7, 2017
1 parent b95c4e8 commit 18bc3dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/hudson/plugins/git/util/GitUtils.java
Expand Up @@ -9,6 +9,7 @@
import hudson.plugins.git.Branch;
import hudson.plugins.git.BranchSpec;
import hudson.plugins.git.GitException;
import hudson.plugins.git.GitObject;
import hudson.plugins.git.Revision;
import hudson.remoting.VirtualChannel;
import hudson.slaves.NodeProperty;
Expand Down Expand Up @@ -76,9 +77,9 @@ public Collection<Revision> getAllBranchRevisions() throws GitException, IOExcep
}
r.getBranches().add(b);
}
for (String tag : git.getTagNames(null)) {
String tagRef = Constants.R_TAGS + tag;
ObjectId objectId = git.revParse(tagRef);
for (GitObject tagEntry : git.getTags()) {
String tagRef = Constants.R_TAGS + tagEntry.getName();
ObjectId objectId = tagEntry.getSHA1();
Revision r = revisions.get(objectId);
if (r == null) {
r = new Revision(objectId);
Expand Down

0 comments on commit 18bc3dc

Please sign in to comment.