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
This commit is contained in:
Shawn Pearce 2013-04-04 15:23:08 -07:00
parent 56497be34d
commit 1eed78657f
2 changed files with 11 additions and 6 deletions

View File

@ -273,6 +273,7 @@ private void packHeads(ProgressMonitor pm) throws IOException {
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 @@ private void packRest(ProgressMonitor pm) throws IOException {
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 @@ private PackWriter newPackWriter() {
PackWriter pw = new PackWriter(packConfig, ctx);
pw.setDeltaBaseAsOffset(true);
pw.setReuseDeltaCommits(false);
pw.setTagTargets(tagTargets);
return pw;
}

View File

@ -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 @@ public ObjectId getDeltaBase() {
@Override
public boolean wasDeltaAttempted() {
PackSource source = pack.getPackDescription().getPackSource();
return source == GC || source == UNREACHABLE_GARBAGE;
return pack.getPackDescription().getPackSource() == GC;
}
}