aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2023-11-17 10:44:56 -0800
committerIvan Frade <ifrade@google.com>2023-11-30 11:58:32 -0800
commit5e563e1ba1114b0c2dc316f0d7d162c9a0956f1b (patch)
treee02b9c7b6554a3554790233175350ed3bff7de0b /org.eclipse.jgit
parent5552242588b8dd4dab155324cc8b12a3c61dd1e5 (diff)
downloadjgit-5e563e1ba1114b0c2dc316f0d7d162c9a0956f1b.tar.gz
jgit-5e563e1ba1114b0c2dc316f0d7d162c9a0956f1b.zip
PackWriter: store the objects with bitmaps in the statistics
We want to know what objects had bitmaps in the walk of the request. We can check their position in the history and evaluate our bitmap selection algorithm. Use the listener interface of the BitmapWalker to get the objects walked with bitmaps and store them in the statistics. Change-Id: Id15a904eb642d7f50d80ac77d1146db4fe4706eb
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java16
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java25
2 files changed, 39 insertions, 2 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 6e02b36ccb..7427598257 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
@@ -68,6 +68,7 @@ import org.eclipse.jgit.lib.AsyncObjectSizeQueue;
import org.eclipse.jgit.lib.BatchingProgressMonitor;
import org.eclipse.jgit.lib.BitmapIndex;
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
+import org.eclipse.jgit.lib.BitmapIndex.BitmapLookupListener;
import org.eclipse.jgit.lib.BitmapObject;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
@@ -2029,8 +2030,19 @@ public class PackWriter implements AutoCloseable {
if (!shallowPack && useBitmaps) {
BitmapIndex bitmapIndex = reader.getBitmapIndex();
if (bitmapIndex != null) {
- BitmapWalker bitmapWalker = new BitmapWalker(
- walker, bitmapIndex, countingMonitor);
+ bitmapIndex.addBitmapLookupListener(new BitmapLookupListener() {
+ @Override
+ public void onBitmapFound(AnyObjectId oid) {
+ stats.objectsWithBitmapsFound.add(oid);
+ }
+
+ @Override
+ public void onBitmapNotFound(AnyObjectId oid) {
+ // Nothing to do
+ }
+ });
+ BitmapWalker bitmapWalker = new BitmapWalker(walker,
+ bitmapIndex, countingMonitor);
findObjectsToPackUsingBitmaps(bitmapWalker, want, have);
endPhase(countingMonitor);
stats.timeCounting = System.currentTimeMillis() - countingStart;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
index 64a1eb2e1a..7c8ed24330 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackStatistics.java
@@ -48,13 +48,16 @@ import static org.eclipse.jgit.lib.Constants.OBJ_TAG;
import static org.eclipse.jgit.lib.Constants.OBJ_TREE;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.storage.pack.CachedPack;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.ObjectId;
/**
@@ -232,6 +235,16 @@ public class PackStatistics {
/** Commits with no parents. */
public Set<ObjectId> rootCommits;
+ /**
+ * Set of objects with bitmap hit when finding objects to pack.
+ *
+ * The size of this set plus {@link #bitmapIndexMisses} should be the
+ * walked size of the graph
+ *
+ * @since 6.9
+ */
+ public Set<AnyObjectId> objectsWithBitmapsFound = new HashSet<>();
+
/** If a shallow pack, the depth in commits. */
public int depth;
@@ -433,6 +446,18 @@ public class PackStatistics {
}
/**
+ * Get unmodifiable collection of objects walked in the request that had a
+ * bitmap.
+ *
+ * @return ummodifiable collection of objects that had a bitmap attached
+ *
+ * @since 6.9
+ */
+ public Set<AnyObjectId> getObjectsWithBitmapsFound() {
+ return Collections.unmodifiableSet(statistics.objectsWithBitmapsFound);
+ }
+
+ /**
* Get unmodifiable list of the cached packs that were reused in the output
*
* @return unmodifiable list of the cached packs that were reused in the