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
This commit is contained in:
Jonathan Nieder 2015-11-03 17:45:06 -08:00
parent 2e8b8e83e2
commit 99d4040094
2 changed files with 18 additions and 5 deletions

View File

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

View File

@ -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