From 99d404009428ef42658cf1aa78069ee5382f6bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 3 Nov 2015 17:45:06 -0800 Subject: [PATCH] Include ancestors of reused bitmap commits in reuse bitmap again Until 320a4142 (Update bitmap selection throttling to fully span active branches, 2015-10-20), setupTipCommitBitmaps contained code along the following lines: for (PackBitmapIndexRemapper.Entry entry : bitmapRemapper) { if (!reuse(entry)) continue; RevCommit rc = (RevCommit) rw.peel(rw.parseAny(entry)); reuseCommits.add(new BitmapCommit(rc)); EWAHCompressedBitmap bitmap = remap.ofObjectType(remap.getBitmap(rc), OBJ_COMMIT); writeBitmaps.addBitmap(rc, bitmap, 0); reuse.add(rc, OBJ_COMMIT); } writeBitmaps.clearBitmaps(); // Remove temporary bitmaps This loop OR-ed together bitmaps for commits whose bitmaps would be reused. A subtle point is the use of the add() method, which ORs in a bitmap from the BitmapIndex when it exists and falls back to OR-ing in a single bit when that bitmap does not exist in the BitmapIndex. Commit 320a4142 removed the addBitmap step, so the bitmap does not exist in the BitmapIndex and the fallback behavior is triggered. Simplify and restore the intended behavior by avoiding use of the subtle use of the add() method --- use or() directly instead. Change-Id: I30844134bfde0cbabdfaab884c84b9809dd8bdb8 --- .../jgit/internal/storage/file/BitmapIndexImpl.java | 11 +++++++++++ .../storage/pack/PackWriterBitmapPreparer.java | 12 +++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java index 5786019e9..0f724af0d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java @@ -92,6 +92,17 @@ public CompressedBitmap getBitmap(AnyObjectId objectId) { return new CompressedBitmap(compressed); } + public CompressedBitmap toBitmap(PackBitmapIndex i, + EWAHCompressedBitmap b) { + if (i != packIndex) { + throw new IllegalArgumentException(); + } + if (b == null) { + return null; + } + return new CompressedBitmap(b); + } + public CompressedBitmapBuilder newBitmapBuilder() { return new CompressedBitmapBuilder(); } 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 e244de790..ed1da4f30 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 @@ -76,6 +76,8 @@ import org.eclipse.jgit.util.BlockList; import org.eclipse.jgit.util.SystemReader; +import com.googlecode.javaewah.EWAHCompressedBitmap; + /** * Helper class for the {@link PackWriter} to select commits for which to build * pack index bitmaps. @@ -347,11 +349,11 @@ private CommitSelectionHelper setupTipCommitBitmaps(RevWalk rw, RevCommit rc = (RevCommit) ro; reuseCommits.add(new BitmapCommit(rc, false, entry.getFlags())); rw.markUninteresting(rc); - // PackBitmapIndexRemapper.ofObjectType() ties the underlying - // bitmap in the old pack into the new bitmap builder. - bitmapRemapper.ofObjectType(bitmapRemapper.getBitmap(rc), - Constants.OBJ_COMMIT).trim(); - reuse.add(rc, Constants.OBJ_COMMIT); + if (!reuse.contains(rc)) { + EWAHCompressedBitmap bitmap = bitmapRemapper.ofObjectType( + bitmapRemapper.getBitmap(rc), Constants.OBJ_COMMIT); + reuse.or(commitBitmapIndex.toBitmap(writeBitmaps, bitmap)); + } } // Add branch tips that are not represented in old bitmap indices. Set