summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-11-03 17:45:06 -0800
committerJonathan Nieder <jrn@google.com>2015-11-03 17:45:06 -0800
commit99d404009428ef42658cf1aa78069ee5382f6bd7 (patch)
treedc1b217f102368bdedc278047e3a56772aa01bb7 /org.eclipse.jgit
parent2e8b8e83e2d4a477a6a60ac41bafe9607876ce67 (diff)
downloadjgit-99d404009428ef42658cf1aa78069ee5382f6bd7.tar.gz
jgit-99d404009428ef42658cf1aa78069ee5382f6bd7.zip
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
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java12
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 5786019e9f..0f724af0d2 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 class BitmapIndexImpl implements BitmapIndex {
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 e244de790b..ed1da4f30a 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.storage.pack.PackConfig;
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 @@ class PackWriterBitmapPreparer {
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