Browse Source

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
stable-4.2
Jonathan Nieder 9 years ago
parent
commit
99d4040094
  1. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
  2. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

11
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();
}

12
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

Loading…
Cancel
Save