diff options
author | Han-Wen Nienhuys <hanwen@google.com> | 2019-11-13 15:23:01 -0800 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-11-16 23:26:42 -0800 |
commit | 0356613f48ebee2e3d2d65780e71d9e0b43a752e (patch) | |
tree | 25a886eb926cf28ff85f2163857a18f770cef1c6 | |
parent | a8f4bf6abef0bb3ca116c65728342928ed43508b (diff) | |
download | jgit-0356613f48ebee2e3d2d65780e71d9e0b43a752e.tar.gz jgit-0356613f48ebee2e3d2d65780e71d9e0b43a752e.zip |
pgm: add write stats to BenchmarkReftable
Usage:
git ls-remote https://gerrit.googlesource.com/gerrit > lsr
bazel build org.eclipse.jgit.pgm:jgit && rm -rf /tmp/reftable* && \
./bazel-bin/org.eclipse.jgit.pgm/jgit debug-benchmark-reftable \
--test write_stack lsr /tmp/reftable
On my Lenovo x250 laptop, this yields about 1ms per ref write.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I31c74a08026ba188a3256ef6862dae9d85e6d5ef
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java index 248eaac8ad..27a7347f3a 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/BenchmarkReftable.java @@ -51,14 +51,18 @@ import static org.eclipse.jgit.lib.Ref.Storage.NEW; import static org.eclipse.jgit.lib.Ref.Storage.PACKED; import java.io.BufferedReader; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.util.List; +import org.eclipse.jgit.internal.storage.file.FileReftableStack; import org.eclipse.jgit.internal.storage.io.BlockSource; import org.eclipse.jgit.internal.storage.reftable.RefCursor; import org.eclipse.jgit.internal.storage.reftable.ReftableReader; +import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectIdRef; import org.eclipse.jgit.lib.Ref; @@ -74,7 +78,8 @@ class BenchmarkReftable extends TextBuiltin { enum Test { SCAN, SEEK_COLD, SEEK_HOT, - BY_ID_COLD, BY_ID_HOT; + BY_ID_COLD, BY_ID_HOT, + WRITE_STACK, } @Option(name = "--tries") @@ -116,6 +121,9 @@ class BenchmarkReftable extends TextBuiltin { case BY_ID_HOT: byIdHot(ObjectId.fromString(objectId)); break; + case WRITE_STACK: + writeStack(); + break; } } @@ -124,6 +132,33 @@ class BenchmarkReftable extends TextBuiltin { } @SuppressWarnings({ "nls", "boxing" }) + private void writeStack() throws Exception { + File dir = new File(reftablePath); + File stackFile = new File(reftablePath + ".stack"); + + dir.mkdirs(); + + long start = System.currentTimeMillis(); + try (FileReftableStack stack = new FileReftableStack(stackFile, dir, + null, () -> new Config())) { + + List<Ref> refs = readLsRemote().asList(); + for (Ref r : refs) { + final long j = stack.getMergedReftable().maxUpdateIndex() + 1; + if (!stack.addReftable(w -> { + w.setMaxUpdateIndex(j).setMinUpdateIndex(j).begin() + .writeRef(r); + })) { + throw new IOException("should succeed"); + } + } + long dt = System.currentTimeMillis() - start; + printf("%12s %10d ms avg %6d us/write", "reftable", dt, + (dt * 1000) / refs.size()); + } + } + + @SuppressWarnings({ "nls", "boxing" }) private void scan() throws Exception { long start, tot; |