Browse Source

Add GC_REST PackSource to better order DFS packs

Force reads to use a search ordering of:

  INSERT / RECEIVE
  COMPACT
  GC (heads)
  GC_REST (non-heads)
  GC_TXN (refs/txn)
  UNREACHABLE_GARBAGE

This has provided decent performance for object lookups.  Starting
from an arbitrary reference may find the content in a newer pack
created by DfsObjectInserter or a ReceivePack server.  Compaction of
recent packs also contains newer content, and then most interesting
data is in the "main" GC pack.  As the GC pack is self-contained (has
no edges leading outside) readers typically do not need to go further.

Adding a new GC_REST PackSource allows the DfsGarbageCollector to
identify to the pack ordering code which pack is which, so the
non-heads are scanned second during reads.  This removes a hack that
was unique to Google's implementation that enforced this behavior by
fixing up the lastModified timestamp.

Renumber the PackSource's categories to reflect this search ordering.

Change-Id: I19fdaab8a8d6687cbe8c88488e6daa0630bf189a
tags/v4.5.0.201609210915-r
Shawn Pearce 8 years ago
parent
commit
30eb6423a2

+ 3
- 1
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsGarbageCollector.java View File

@@ -44,6 +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.GC_REST;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.GC_TXN;
import static org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
import static org.eclipse.jgit.internal.storage.pack.PackExt.BITMAP_INDEX;
@@ -299,6 +300,7 @@ public class DfsGarbageCollector {
writePack(GC, pw, pm);
}
}

private void packRest(ProgressMonitor pm) throws IOException {
if (nonHeads.isEmpty())
return;
@@ -308,7 +310,7 @@ public class DfsGarbageCollector {
pw.excludeObjects(packedObjs);
pw.preparePack(pm, nonHeads, allHeads);
if (0 < pw.getObjectCount())
writePack(GC, pw, pm);
writePack(GC_REST, pw, pm);
}
}


+ 17
- 14
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsObjDatabase.java View File

@@ -79,6 +79,17 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
*/
RECEIVE(0),

/**
* The pack was created by compacting multiple packs together.
* <p>
* Packs created by compacting multiple packs together aren't nearly as
* efficient as a fully garbage collected repository, but may save disk
* space by reducing redundant copies of base objects.
*
* @see DfsPackCompactor
*/
COMPACT(1),

/**
* Pack was created by Git garbage collection by this implementation.
* <p>
@@ -88,25 +99,17 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
*
* @see DfsGarbageCollector
*/
GC(1),
GC(2),

/** Created from non-heads by {@link DfsGarbageCollector}. */
GC_REST(3),

/**
* RefTreeGraph pack was created by Git garbage collection.
*
* @see DfsGarbageCollector
*/
GC_TXN(1),

/**
* The pack was created by compacting multiple packs together.
* <p>
* Packs created by compacting multiple packs together aren't nearly as
* efficient as a fully garbage collected repository, but may save disk
* space by reducing redundant copies of base objects.
*
* @see DfsPackCompactor
*/
COMPACT(1),
GC_TXN(4),

/**
* Pack was created by Git garbage collection.
@@ -115,7 +118,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
* last GC pass. It is retained in a new pack until it is safe to prune
* these objects from the repository.
*/
UNREACHABLE_GARBAGE(2);
UNREACHABLE_GARBAGE(5);

final int category;


Loading…
Cancel
Save