From 0e8ac496cd9bbfa3fa306ac45706f501fc24ac38 Mon Sep 17 00:00:00 2001 From: Terry Parker Date: Mon, 11 May 2015 17:37:02 -0700 Subject: [PATCH] Add bitmap index misses to PackWriter.Statistics RevWalks to find commits that are not in bitmap indices are expensive. Track the count of commits that are enumerated via RevWalks as "bitmap index misses" in the PackWriter.Statistics class. Change-Id: Ie0135a0a0aeba2dfb6df78839d545006629f16cb Signed-off-by: Terry Parker --- .../internal/storage/pack/PackWriter.java | 13 +++++++++++ .../storage/pack/PackWriterBitmapWalker.java | 22 ++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java index 8fac90727..adc6bf11a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java @@ -1591,6 +1591,7 @@ private void findObjectsToPack(final ProgressMonitor countingMonitor, findObjectsToPackUsingBitmaps(bitmapWalker, want, have); endPhase(countingMonitor); stats.timeCounting = System.currentTimeMillis() - countingStart; + stats.bitmapIndexMisses = bitmapWalker.getCountOfBitmapIndexMisses(); return; } } @@ -2084,6 +2085,8 @@ public long getDeltaBytes() { long totalObjects; + long bitmapIndexMisses; + long totalDeltas; long reusedObjects; @@ -2165,6 +2168,16 @@ public long getTotalObjects() { return totalObjects; } + /** + * @return the count of objects that needed to be discovered through an + * object walk because they were not found in bitmap indices. + * + * @since 4.0 + */ + public long getBitmapIndexMisses() { + return bitmapIndexMisses; + } + /** * @return total number of deltas output. This may be lower than the * actual number of deltas if a cached pack was reused. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java index 63a91cd82..debb2f2ab 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java @@ -71,6 +71,8 @@ final class PackWriterBitmapWalker { private final ProgressMonitor pm; + private long countOfBitmapIndexMisses; + PackWriterBitmapWalker( ObjectWalk walker, BitmapIndex bitmapIndex, ProgressMonitor pm) { this.walker = walker; @@ -78,6 +80,10 @@ final class PackWriterBitmapWalker { this.pm = (pm == null) ? NullProgressMonitor.INSTANCE : pm; } + long getCountOfBitmapIndexMisses() { + return countOfBitmapIndexMisses; + } + BitmapBuilder findObjects(Set start, BitmapBuilder seen, boolean ignoreMissingStart) throws MissingObjectException, IncorrectObjectTypeException, IOException { @@ -104,7 +110,8 @@ BitmapBuilder findObjects(Set start, BitmapBuilder seen, boo } if (marked) { - walker.setRevFilter(newRevFilter(seen, bitmapResult)); + BitmapRevFilter filter = newRevFilter(seen, bitmapResult); + walker.setRevFilter(filter); while (walker.next() != null) { // Iterate through all of the commits. The BitmapRevFilter does @@ -117,6 +124,7 @@ BitmapBuilder findObjects(Set start, BitmapBuilder seen, boo bitmapResult.add(ro, ro.getType()); pm.update(1); } + countOfBitmapIndexMisses += filter.getCountOfLoadedCommits(); } return bitmapResult; @@ -126,7 +134,7 @@ void reset() { walker.reset(); } - static RevFilter newRevFilter( + static BitmapRevFilter newRevFilter( final BitmapBuilder seen, final BitmapBuilder bitmapResult) { if (seen != null) { return new BitmapRevFilter() { @@ -146,12 +154,16 @@ protected boolean load(RevCommit cmit) { } static abstract class BitmapRevFilter extends RevFilter { + private long countOfLoadedCommits; + protected abstract boolean load(RevCommit cmit); @Override public final boolean include(RevWalk walker, RevCommit cmit) { - if (load(cmit)) + if (load(cmit)) { + countOfLoadedCommits++; return true; + } for (RevCommit p : cmit.getParents()) p.add(RevFlag.SEEN); return false; @@ -166,5 +178,9 @@ public final RevFilter clone() { public final boolean requiresCommitBody() { return false; } + + long getCountOfLoadedCommits() { + return countOfLoadedCommits; + } } }