Fix: Performance issue when traversing large Git repositories

The commit:

	3488eece9f
	"Verify access to source ref during add branch operation"

introduced a performance issue on Git repositories with
many refs and large commit graphs. Tree traversal,
to verify visibility of initial revision, included namespaces
whose tips are not reachable from any branch. Iterating over
all these refs ended up stalling our system.

By filtering the refs, so that only "refs/heads" and "refs/tags"
namespaces are traversed, time was reduced from 1h+ to ~10 seconds
for a create branch operation.

Change-Id: I64c1123cc092fa5a7de6db8be7999672bd9f67b0
This commit is contained in:
Sven Selberg
2013-11-13 16:04:35 +01:00
committed by Gustaf Lundh
parent e5b7f1aa5c
commit 8b49b130ef

View File

@@ -469,6 +469,10 @@ public class ProjectControl {
Repository repo = repoManager.openRepository(projName);
try {
for (Entry<String, Ref> entry : repo.getAllRefs().entrySet()) {
String refName = entry.getKey();
if (!refName.startsWith("refs/heads") && !refName.startsWith("refs/tags")) {
continue;
}
RevCommit tip;
try {
tip = rw.parseCommit(entry.getValue().getObjectId());