summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.benchmarks
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-01-20 00:18:25 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-01-20 00:37:52 +0100
commitb5bfa90a9e2deb13b5151e5d9885db741b2e7f7a (patch)
tree41f528493fac42185f1ced1c1851ba68cdba6634 /org.eclipse.jgit.benchmarks
parent11bb889d0b5d386d04751d7380c6be082ffc9112 (diff)
parentb4c66104fb7502f133989291a4a5595f965771d3 (diff)
downloadjgit-b5bfa90a9e2deb13b5151e5d9885db741b2e7f7a.tar.gz
jgit-b5bfa90a9e2deb13b5151e5d9885db741b2e7f7a.zip
Merge branch 'stable-6.6' into stable-6.7
* stable-6.6: Introduce a PriorityQueue sorting RevCommits by commit timestamp Remove org.eclipse.jgit.benchmark/.factorypath Update jmh to 1.37 for org.eclipse.jgit.benchmark Change-Id: I76ebca527e523f124bfe81c821169c790eddccb6
Diffstat (limited to 'org.eclipse.jgit.benchmarks')
-rw-r--r--org.eclipse.jgit.benchmarks/.classpath15
-rw-r--r--org.eclipse.jgit.benchmarks/.factorypath29
-rw-r--r--org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/revwalk/DateRevQueueBenchmark.java137
3 files changed, 139 insertions, 42 deletions
diff --git a/org.eclipse.jgit.benchmarks/.classpath b/org.eclipse.jgit.benchmarks/.classpath
index 8dcf94ed9c..01d71610e6 100644
--- a/org.eclipse.jgit.benchmarks/.classpath
+++ b/org.eclipse.jgit.benchmarks/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes" path="src">
+ <classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@@ -19,18 +19,7 @@
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- <attribute name="ignore_optional_problems" value="true"/>
- <attribute name="m2e-apt" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- <attribute name="ignore_optional_problems" value="true"/>
- <attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
-</classpath> \ No newline at end of file
+</classpath>
diff --git a/org.eclipse.jgit.benchmarks/.factorypath b/org.eclipse.jgit.benchmarks/.factorypath
deleted file mode 100644
index c631d4ac84..0000000000
--- a/org.eclipse.jgit.benchmarks/.factorypath
+++ /dev/null
@@ -1,29 +0,0 @@
-<factorypath>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/openjdk/jmh/jmh-generator-annprocess/1.32/jmh-generator-annprocess-1.32.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/openjdk/jmh/jmh-core/1.32/jmh-core-1.32.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_core/2.9.0/error_prone_core-2.9.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_annotation/2.9.0/error_prone_annotation-2.9.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_type_annotations/2.9.0/error_prone_type_annotations-2.9.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_check_api/2.9.0/error_prone_check_api-2.9.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/io/github/java-diff-utils/java-diff-utils/4.0/java-diff-utils-4.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/eclipse/jgit/org.eclipse.jgit/4.4.1.201607150455-r/org.eclipse.jgit-4.4.1.201607150455-r.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/github/kevinstern/software-and-algorithms/1.0/software-and-algorithms-1.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/github/ben-manes/caffeine/caffeine/2.8.8/caffeine-2.8.8.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/pcollections/pcollections/2.1.2/pcollections-2.1.2.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/auto/auto-common/1.1.2/auto-common-1.1.2.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/findbugs/jFormatString/3.0.0/jFormatString-3.0.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/findbugs/jsr305/3.0.0/jsr305-3.0.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/org/checkerframework/dataflow-errorprone/3.15.0/dataflow-errorprone-3.15.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/javac/9+181-r4173-1/javac-9+181-r4173-1.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/auto/value/auto-value-annotations/1.7/auto-value-annotations-1.7.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/errorprone/error_prone_annotations/2.9.0/error_prone_annotations-2.9.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/protobuf/protobuf-java/3.4.0/protobuf-java-3.4.0.jar" enabled="true" runInBatchMode="false"/>
- <factorypathentry kind="VARJAR" id="M2_REPO/com/google/auto/service/auto-service-annotations/1.0-rc6/auto-service-annotations-1.0-rc6.jar" enabled="true" runInBatchMode="false"/>
-</factorypath>
diff --git a/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/revwalk/DateRevQueueBenchmark.java b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/revwalk/DateRevQueueBenchmark.java
new file mode 100644
index 0000000000..71075a8b4c
--- /dev/null
+++ b/org.eclipse.jgit.benchmarks/src/org/eclipse/jgit/revwalk/DateRevQueueBenchmark.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2023, GerritForge Ltd
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.revwalk;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.junit.TestRepository;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.util.FileUtils;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+@State(Scope.Thread)
+public class DateRevQueueBenchmark {
+
+ ThreadLocalRandom commitsIndex = ThreadLocalRandom.current();
+
+ @State(Scope.Benchmark)
+ public static class BenchmarkState {
+
+ @Param({ "5", "10", "50", "100", "500", "1000", "5000", "10000",
+ "50000", "100000", "500000" })
+ int numCommits;
+
+ @Param({ "true", "false" })
+ boolean usePriorityQueue;
+
+ int low, count;
+
+ RevCommit[] commits = new RevCommit[numCommits];
+
+ private Path testDir;
+
+ private TestRepository<Repository> repoUtil;
+
+ DateRevQueue queue;
+
+ @Setup
+ public void setupBenchmark() throws Exception {
+ testDir = Files.createTempDirectory("testrepos");
+ String repoName = "commits-" + numCommits + "-usePriorityQueue-"
+ + usePriorityQueue;
+ Path workDir = testDir.resolve(repoName);
+ Git git = Git.init().setDirectory(workDir.toFile()).call();
+ repoUtil = new TestRepository<>(git.getRepository());
+
+ RevCommit parent = repoUtil.commit().create();
+ commits = new RevCommit[numCommits];
+ commits[0] = parent;
+ for (int i = 1; i < numCommits; i++) {
+ parent = repoUtil.parseBody(repoUtil.commit(i, parent));
+ commits[i] = parent;
+ if (i % 10000 == 0) {
+ System.out.println(" " + i + " done");
+ }
+ }
+
+ if (usePriorityQueue) {
+ queue = new DateRevPriorityQueue(false);
+ } else {
+ queue = new DateRevQueue(false);
+ }
+
+ low = 9 * numCommits / 10;
+ ThreadLocalRandom random = ThreadLocalRandom.current();
+ // add 90% * numCommits commits, benchmark adding commits from
+ // 90-100%
+ for (int i = 0; i < low; i++) {
+ RevCommit commit = commits[random.nextInt(numCommits)];
+ queue.add(commit);
+ ++count;
+ }
+ }
+
+ @TearDown(Level.Invocation)
+ public void check() {
+ // if queue is full remove 10% of its entries
+ if (++count == numCommits) {
+ do {
+ queue.next();
+ } while (--count > low);
+ }
+ }
+
+ @TearDown
+ public void teardown() throws IOException {
+ repoUtil.close();
+ FileUtils.delete(testDir.toFile(),
+ FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
+ }
+
+ @Benchmark
+ @BenchmarkMode({ Mode.AverageTime })
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
+ @Warmup(iterations = 2, time = 100, timeUnit = TimeUnit.MILLISECONDS)
+ @Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.SECONDS)
+ public void testDataRevQueue(BenchmarkState state) throws Exception {
+ RevCommit commit = state.commits[commitsIndex
+ .nextInt(state.numCommits)];
+ state.queue.add(commit);
+ }
+
+ public static void main(String[] args) throws RunnerException {
+ Options opt = new OptionsBuilder()
+ .include(DateRevQueueBenchmark.class.getSimpleName()).forks(1)
+ .jvmArgs("-ea").build();
+ new Runner(opt).run();
+ }
+
+}