Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2011-03-18 16:10:07 +0000
committerShawn O. Pearce2011-04-01 21:40:33 +0000
commit36a38adf719330a14ddd3f0bf8859cde0166d2ce (patch)
treeb22bf2772d94747a4c3dd7f01f528eb6238f0d9a
parent0be24ebf33974d4f1512644608769cb82d1782ea (diff)
downloadjgit-36a38adf719330a14ddd3f0bf8859cde0166d2ce.tar.gz
jgit-36a38adf719330a14ddd3f0bf8859cde0166d2ce.tar.xz
jgit-36a38adf719330a14ddd3f0bf8859cde0166d2ce.zip
PackWriter: Combine small reuse batches together
If the total number of objects to look for reuse on is under 4096 this is really close to a reasonable batch size for the DHT storage system to lookup at once. Combine all of the objects into a single temporary list, perform reuse, and then prune the main lists if any duplicate objects were detected from a selected CachedPack. The intention here is to try and avoid 4 tiny sequential lookups on the storage system when the time to wait for each of those to finish is higher than the CPU time required to build (and later GC) this temporary list. Change-Id: I528daf9d2f7744dc4a6281750c2d61d8f9da9f3a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
index 5f3599d8c2..c388ee17d4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java
@@ -722,10 +722,30 @@ public class PackWriter {
long start = System.currentTimeMillis();
monitor.beginTask(JGitText.get().searchForReuse, cnt);
- searchForReuse(monitor, objectsLists[Constants.OBJ_COMMIT]);
- searchForReuse(monitor, objectsLists[Constants.OBJ_TREE]);
- searchForReuse(monitor, objectsLists[Constants.OBJ_BLOB]);
- searchForReuse(monitor, objectsLists[Constants.OBJ_TAG]);
+
+ if (cnt <= 4096) {
+ // For small object counts, do everything as one list.
+ BlockList<ObjectToPack> tmp = new BlockList<ObjectToPack>(cnt);
+ tmp.addAll(objectsLists[Constants.OBJ_COMMIT]);
+ tmp.addAll(objectsLists[Constants.OBJ_TREE]);
+ tmp.addAll(objectsLists[Constants.OBJ_BLOB]);
+ tmp.addAll(objectsLists[Constants.OBJ_TAG]);
+ searchForReuse(monitor, tmp);
+ if (pruneCurrentObjectList) {
+ // If the list was pruned, we need to re-prune the main lists.
+ pruneEdgesFromObjectList(objectsLists[Constants.OBJ_COMMIT]);
+ pruneEdgesFromObjectList(objectsLists[Constants.OBJ_TREE]);
+ pruneEdgesFromObjectList(objectsLists[Constants.OBJ_BLOB]);
+ pruneEdgesFromObjectList(objectsLists[Constants.OBJ_TAG]);
+ }
+
+ } else {
+ searchForReuse(monitor, objectsLists[Constants.OBJ_COMMIT]);
+ searchForReuse(monitor, objectsLists[Constants.OBJ_TREE]);
+ searchForReuse(monitor, objectsLists[Constants.OBJ_BLOB]);
+ searchForReuse(monitor, objectsLists[Constants.OBJ_TAG]);
+ }
+
monitor.endTask();
stats.timeSearchingForReuse = System.currentTimeMillis() - start;
}

Back to the top