Merge "DfsGarbageCollector: provide commit graph stats"
This commit is contained in:
commit
f8f5979aa2
|
@ -20,6 +20,7 @@
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraph;
|
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraph;
|
||||||
|
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraphWriter;
|
||||||
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
|
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
|
||||||
import org.eclipse.jgit.internal.storage.reftable.RefCursor;
|
import org.eclipse.jgit.internal.storage.reftable.RefCursor;
|
||||||
import org.eclipse.jgit.internal.storage.reftable.ReftableConfig;
|
import org.eclipse.jgit.internal.storage.reftable.ReftableConfig;
|
||||||
|
@ -1103,6 +1104,22 @@ public void commitGraphWithoutGCrestPack() throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void produceCommitGraphAndBloomFilter() throws Exception {
|
||||||
|
String head = "refs/heads/head1";
|
||||||
|
|
||||||
|
git.branch(head).commit().message("0").noParents().create();
|
||||||
|
|
||||||
|
gcWithCommitGraphAndBloomFilter();
|
||||||
|
|
||||||
|
assertEquals(1, odb.getPacks().length);
|
||||||
|
DfsPackFile pack = odb.getPacks()[0];
|
||||||
|
DfsPackDescription desc = pack.getPackDescription();
|
||||||
|
CommitGraphWriter.Stats stats = desc.getCommitGraphStats();
|
||||||
|
assertNotNull(stats);
|
||||||
|
assertEquals(1, stats.getChangedPathFiltersComputed());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void objectSizeIdx_reachableBlob_bigEnough_indexed() throws Exception {
|
public void objectSizeIdx_reachableBlob_bigEnough_indexed() throws Exception {
|
||||||
String master = "refs/heads/master";
|
String master = "refs/heads/master";
|
||||||
|
@ -1177,6 +1194,13 @@ private void gcWithCommitGraph() throws IOException {
|
||||||
run(gc);
|
run(gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void gcWithCommitGraphAndBloomFilter() throws IOException {
|
||||||
|
DfsGarbageCollector gc = new DfsGarbageCollector(repo);
|
||||||
|
gc.setWriteCommitGraph(true);
|
||||||
|
gc.setWriteBloomFilter(true);
|
||||||
|
run(gc);
|
||||||
|
}
|
||||||
|
|
||||||
private void gcWithObjectSizeIndex(int threshold) throws IOException {
|
private void gcWithObjectSizeIndex(int threshold) throws IOException {
|
||||||
DfsGarbageCollector gc = new DfsGarbageCollector(repo);
|
DfsGarbageCollector gc = new DfsGarbageCollector(repo);
|
||||||
gc.getPackConfig().setMinBytesForObjSizeIndex(threshold);
|
gc.getPackConfig().setMinBytesForObjSizeIndex(threshold);
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.JGitText;
|
import org.eclipse.jgit.internal.JGitText;
|
||||||
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraphWriter;
|
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraphWriter;
|
||||||
|
@ -789,10 +788,11 @@ private void writeCommitGraph(DfsPackDescription pack, ProgressMonitor pm)
|
||||||
CountingOutputStream cnt = new CountingOutputStream(out);
|
CountingOutputStream cnt = new CountingOutputStream(out);
|
||||||
CommitGraphWriter writer = new CommitGraphWriter(gcs,
|
CommitGraphWriter writer = new CommitGraphWriter(gcs,
|
||||||
writeBloomFilter);
|
writeBloomFilter);
|
||||||
writer.write(pm, cnt);
|
CommitGraphWriter.Stats stats = writer.write(pm, cnt);
|
||||||
pack.addFileExt(COMMIT_GRAPH);
|
pack.addFileExt(COMMIT_GRAPH);
|
||||||
pack.setFileSize(COMMIT_GRAPH, cnt.getCount());
|
pack.setFileSize(COMMIT_GRAPH, cnt.getCount());
|
||||||
pack.setBlockSize(COMMIT_GRAPH, out.blockSize());
|
pack.setBlockSize(COMMIT_GRAPH, out.blockSize());
|
||||||
|
pack.setCommitGraphStats(stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import org.eclipse.jgit.annotations.NonNull;
|
import org.eclipse.jgit.annotations.NonNull;
|
||||||
|
import org.eclipse.jgit.internal.storage.commitgraph.CommitGraphWriter;
|
||||||
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
|
import org.eclipse.jgit.internal.storage.dfs.DfsObjDatabase.PackSource;
|
||||||
import org.eclipse.jgit.internal.storage.pack.PackExt;
|
import org.eclipse.jgit.internal.storage.pack.PackExt;
|
||||||
import org.eclipse.jgit.internal.storage.reftable.ReftableWriter;
|
import org.eclipse.jgit.internal.storage.reftable.ReftableWriter;
|
||||||
|
@ -144,6 +145,7 @@ static Comparator<DfsPackDescription> reuseComparator() {
|
||||||
|
|
||||||
private PackStatistics packStats;
|
private PackStatistics packStats;
|
||||||
private ReftableWriter.Stats refStats;
|
private ReftableWriter.Stats refStats;
|
||||||
|
private CommitGraphWriter.Stats commitGraphStats;
|
||||||
private int extensions;
|
private int extensions;
|
||||||
private int indexVersion;
|
private int indexVersion;
|
||||||
private long estimatedPackSize;
|
private long estimatedPackSize;
|
||||||
|
@ -480,6 +482,19 @@ void setReftableStats(ReftableWriter.Stats stats) {
|
||||||
setBlockSize(REFTABLE, stats.refBlockSize());
|
setBlockSize(REFTABLE, stats.refBlockSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get stats from the sibling commit graph, if created.
|
||||||
|
*
|
||||||
|
* @return stats from the sibling commit graph, if created.
|
||||||
|
*/
|
||||||
|
public CommitGraphWriter.Stats getCommitGraphStats() {
|
||||||
|
return commitGraphStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setCommitGraphStats(CommitGraphWriter.Stats stats) {
|
||||||
|
this.commitGraphStats = stats;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discard the pack statistics, if it was populated.
|
* Discard the pack statistics, if it was populated.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue