diff options
author | jackdt@google.com <jackdt@google.com> | 2024-02-07 19:12:46 +0000 |
---|---|---|
committer | jackdt@google.com <jackdt@google.com> | 2024-02-07 21:16:46 +0000 |
commit | 15363e4c3bb2a44fd2ec983786c1c966aacfc076 (patch) | |
tree | e725bd9d318a0b088290353dd524cc6413893473 | |
parent | e6d83d61eade6dee223757d149a4df9650752a55 (diff) | |
download | jgit-15363e4c3bb2a44fd2ec983786c1c966aacfc076.tar.gz jgit-15363e4c3bb2a44fd2ec983786c1c966aacfc076.zip |
PackWriterBitmapPreparer: Do not generate bitmaps for excessive branch tips.
In https://review.gerrithub.io/c/eclipse-jgit/jgit/+/1174407, I changed the bitmap selection algorithm to cap the number of branches included in the bitmap.
There was a bug in that change. When the selection algorithm iterates
over the commits in a branch B, it automatically includes a bitmap for
the tip of any other branch C that happens to be on B. So even though we never iterated over C, we would still index the tip commit of C.
Keep a list of the "excessive" branch tips and check that the commit is not in there before generating a bitmap. We only skip tips that would be selected as a result of being a tip. If it would be selected for some other reason (e.g. it is one of the first 100 commits in master) then it is not skipped.
Change-Id: Ic8b4f82e816eac649a47c8918a41ed4ff0d877cd
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java index 0c67b45344..dabc1f0c5f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java @@ -166,8 +166,11 @@ class PackWriterBitmapPreparer { rw2.setRetainBody(false); rw2.setRevFilter(new NotInBitmapFilter(seen)); - int maxBranches = Math.min(excessiveBranchTipCount, - selectionHelper.newWantsByNewest.size()); + int newWantsCount = selectionHelper.newWantsByNewest.size(); + int maxBranches = Math.min(excessiveBranchTipCount, newWantsCount); + Set<RevCommit> excessiveBranches = new HashSet<>( + selectionHelper.newWantsByNewest.subList(maxBranches, + newWantsCount)); // For each branch, do a revwalk to enumerate its commits. Exclude // both reused commits and any commits seen in a previous branch. // Then iterate through all new commits from oldest to newest, @@ -229,7 +232,7 @@ class PackWriterBitmapPreparer { pm.update(1); // Always pick the items in wants, prefer merge commits. - if (selectionHelper.newWants.remove(c)) { + if (!excessiveBranches.contains(c) && selectionHelper.newWants.remove(c)) { if (nextIn > 0) { nextFlg = 0; } |