Browse Source

Don't delta compress garbage objects

Garbage is randomly ordered and unlikely to delta compress against
other garbage. Disable delta compression allowing objects to switch
to whole form when moving to the garbage pack.

Because the garbage is not well compressed assume deltas were not
attempted during a normal GC cycle.

Override the reuse settings, garbage that can be reused should be
reused as-is into the garbage pack rather than switching something
like the compression level during a GC. It is intended that garbage
will eventually be removed from the repository so expending CPU
time on a compression switch is not worthwhile.

Change-Id: I0e8e58ee99e5011d375d3d89c94f2957de8402b9
stable-3.0
Shawn Pearce 12 years ago
parent
commit
1eed78657f
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java
  2. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjectRepresentation.java

12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java

@ -273,6 +273,7 @@ public class DfsGarbageCollector {
PackWriter pw = newPackWriter();
try {
pw.setTagTargets(tagTargets);
pw.preparePack(pm, allHeads, Collections.<ObjectId> emptySet());
if (0 < pw.getObjectCount())
writePack(GC, pw, pm);
@ -299,7 +300,15 @@ public class DfsGarbageCollector {
private void packGarbage(ProgressMonitor pm) throws IOException {
// TODO(sop) This is ugly. The garbage pack needs to be deleted.
PackWriter pw = newPackWriter();
PackConfig cfg = new PackConfig(packConfig);
cfg.setReuseDeltas(true);
cfg.setReuseObjects(true);
cfg.setDeltaCompress(false);
cfg.setBuildBitmaps(false);
PackWriter pw = new PackWriter(cfg, ctx);
pw.setDeltaBaseAsOffset(true);
pw.setReuseDeltaCommits(true);
try {
RevWalk pool = new RevWalk(ctx);
pm.beginTask("Finding garbage", objectsBefore());
@ -345,7 +354,6 @@ public class DfsGarbageCollector {
PackWriter pw = new PackWriter(packConfig, ctx);
pw.setDeltaBaseAsOffset(true);
pw.setReuseDeltaCommits(false);
pw.setTagTargets(tagTargets);
return pw;
}

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjectRepresentation.java

@ -44,9 +44,7 @@
package org.eclipse.jgit.internal.storage.dfs;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
import org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation;
import org.eclipse.jgit.lib.ObjectId;
@ -80,7 +78,6 @@ class DfsObjectRepresentation extends StoredObjectRepresentation {
@Override
public boolean wasDeltaAttempted() {
PackSource source = pack.getPackDescription().getPackSource();
return source == GC || source == UNREACHABLE_GARBAGE;
return pack.getPackDescription().getPackSource() == GC;
}
}

Loading…
Cancel
Save