Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openjdk/jmh
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.32
Choose a base ref
...
head repository: openjdk/jmh
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.33
Choose a head ref
  • 6 commits
  • 23 files changed
  • 2 contributors

Commits on May 26, 2021

  1. Continue in 1.33-SNAPSHOT

    shipilev committed May 26, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    sxzz Kevin Deng 三咲智子
    Copy the full SHA
    6696c74 View commit details

Commits on Jul 30, 2021

  1. Copy the full SHA
    0d2a820 View commit details

Commits on Aug 2, 2021

  1. 7903001: JMH: The interrupt to time-outing benchmark can be delivered…

    … to warmdown latches
    
    Reviewed-by: ecaspole
    shipilev committed Aug 2, 2021
    Copy the full SHA
    3f72071 View commit details
  2. 7903003: JMH: Print a single interruption message per iteration

    Reviewed-by: ecaspole
    shipilev committed Aug 2, 2021
    Copy the full SHA
    dd6e963 View commit details

Commits on Aug 6, 2021

  1. Copy the full SHA
    b8f1d77 View commit details

Commits on Aug 9, 2021

  1. JMH v1.33.

    shipilev committed Aug 9, 2021
    Copy the full SHA
    066da6a View commit details
2 changes: 1 addition & 1 deletion jmh-archetypes/jmh-groovy-benchmark-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-archetypes</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<artifactId>jmh-groovy-benchmark-archetype</artifactId>
2 changes: 1 addition & 1 deletion jmh-archetypes/jmh-java-benchmark-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-archetypes</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<artifactId>jmh-java-benchmark-archetype</artifactId>
2 changes: 1 addition & 1 deletion jmh-archetypes/jmh-kotlin-benchmark-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-archetypes</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<artifactId>jmh-kotlin-benchmark-archetype</artifactId>
2 changes: 1 addition & 1 deletion jmh-archetypes/jmh-scala-benchmark-archetype/pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-archetypes</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<artifactId>jmh-scala-benchmark-archetype</artifactId>
2 changes: 1 addition & 1 deletion jmh-archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-parent</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<name>JMH Archetypes</name>
2 changes: 1 addition & 1 deletion jmh-core-benchmarks/pom.xml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-parent</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<name>JMH Core Benchmarks</name>
2 changes: 1 addition & 1 deletion jmh-core-ct/pom.xml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-parent</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<name>JMH Core Compilation Tests</name>
44 changes: 23 additions & 21 deletions jmh-core-ct/src/test/java/org/openjdk/jmh/ct/CompileTest.java
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
import org.openjdk.jmh.generators.core.GeneratorSource;
import org.openjdk.jmh.generators.reflection.RFGeneratorSource;
import org.openjdk.jmh.util.FileUtils;
import org.openjdk.jmh.util.JDKVersion;
import org.openjdk.jmh.util.Utils;

import javax.tools.*;
@@ -109,33 +110,34 @@ private static boolean doTest(Class<?> klass, InMemoryGeneratorDestination desti
}

private static Collection<String> javacOptions(boolean annProc, Class<?> klass) {
Collection<String> result = new ArrayList<>();

if (!annProc) {
result.add("-proc:none");
}

// These tests print warnings (as designed), so -Werror fails.
if (klass.equals(SwingTest.class)) {
if (annProc) {
return Collections.emptyList();
} else {
return Collections.singleton("-proc:none");
}
boolean noWerror = klass.equals(SwingTest.class);

if (!noWerror) {
result.add("-Werror");
}

// These tests fail when generated code references the static target
// through the instance.
if (klass.equals(GenericReturnTest.class) ||
klass.equals(PublicStaticBenchmarkTest.class) ||
klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class)) {
if (annProc) {
return Arrays.asList("-Xlint:all,-processing,-static", "-Werror");
} else {
return Arrays.asList("-proc:none", "-Xlint:all,-static", "-Werror");
}
}
boolean noStatic = klass.equals(GenericReturnTest.class) ||
klass.equals(PublicStaticBenchmarkTest.class) ||
klass.equals(PublicSynchronizedStaticBenchmarkStateBenchmarkTest.class);

// Regular tests should compile with full lint and Werror.
if (annProc) {
return Arrays.asList("-Xlint:all,-processing", "-Werror");
} else {
return Arrays.asList("-proc:none", "-Xlint:all", "-Werror");
}
// JDK 17 introduces a new warning about unnecessary strictfp use.
boolean noStrictFPChecks = JDKVersion.parseMajor(System.getProperty("java.version")) >= 17;

result.add("-Xlint:all" +
(annProc ? ",-processing" : "") +
(noStatic ? ",-static" : "") +
(noStrictFPChecks ? ",-strictfp" : ""));

return result;
}

public static boolean doTestOther(Class<?> klass, GeneratorSource source, InMemoryGeneratorDestination destination) {
2 changes: 1 addition & 1 deletion jmh-core-it/pom.xml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-parent</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<name>JMH Core Integration Tests</name>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.jmh.it.interrupts;

import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class InterruptibleInterruptTest {

@Benchmark
public void test() {
try {
Thread.sleep(5_000);
} catch (InterruptedException e) {
// Harness delivered, just exit.
}
}

@Test
public void invokeAPI() throws RunnerException {
for (Mode m : Mode.values()) {
if (m != Mode.All) continue;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.mode(m)
.timeout(TimeValue.seconds(1))
.build();

new Runner(opt).run();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.jmh.it.interrupts;

import org.junit.Test;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.it.Fixtures;
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;
import org.openjdk.jmh.runner.options.TimeValue;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(1)
public class NonInterruptibleInterruptTest {

@Benchmark
public void test() {
// This method deliberately does not check interrupt status.
long start = System.currentTimeMillis();
long end = start + 5_000;
while (System.currentTimeMillis() < end) {
Blackhole.consumeCPU(10_000);
}
}

@Test
public void invokeAPI() throws RunnerException {
for (Mode m : Mode.values()) {
if (m != Mode.All) continue;
Options opt = new OptionsBuilder()
.include(Fixtures.getTestMask(this.getClass()))
.shouldFailOnError(true)
.mode(m)
.timeout(TimeValue.seconds(1))
.build();

new Runner(opt).run();
}
}

}
2 changes: 1 addition & 1 deletion jmh-core/pom.xml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ questions.
<parent>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-parent</artifactId>
<version>1.32</version>
<version>1.33</version>
</parent>

<name>JMH Core</name>
Original file line number Diff line number Diff line change
@@ -595,10 +595,10 @@ private void generateThroughput(PrintWriter writer, Mode benchmarkKind, MethodGr

writer.println(ident(5) + "res.allOps++;");
writer.println(ident(4) + "}");
writer.println(ident(4) + "control.preTearDown();");
writer.println(ident(3) + "} catch (InterruptedException ie) {");
writer.println(ident(4) + "control.preTearDownForce();");
writer.println(ident(3) + "} catch (Throwable e) {");
writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;");
writer.println(ident(3) + "}");
writer.println(ident(3) + "control.preTearDown();");

// iteration prolog
iterationEpilog(writer, 3, method, states);
@@ -728,10 +728,10 @@ private void generateAverageTime(PrintWriter writer, Mode benchmarkKind, MethodG

writer.println(ident(5) + "res.allOps++;");
writer.println(ident(4) + "}");
writer.println(ident(4) + "control.preTearDown();");
writer.println(ident(3) + "} catch (InterruptedException ie) {");
writer.println(ident(4) + "control.preTearDownForce();");
writer.println(ident(3) + "} catch (Throwable e) {");
writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;");
writer.println(ident(3) + "}");
writer.println(ident(3) + "control.preTearDown();");

iterationEpilog(writer, 3, method, states);

@@ -891,10 +891,10 @@ private void generateSampleTime(PrintWriter writer, Mode benchmarkKind, MethodGr

writer.println(ident(5) + "res.allOps++;");
writer.println(ident(4) + "}");
writer.println(ident(4) + "control.preTearDown();");
writer.println(ident(3) + "} catch (InterruptedException ie) {");
writer.println(ident(4) + "control.preTearDownForce();");
writer.println(ident(3) + "} catch (Throwable e) {");
writer.println(ident(4) + "if (!(e instanceof InterruptedException)) throw e;");
writer.println(ident(3) + "}");
writer.println(ident(3) + "control.preTearDown();");

iterationEpilog(writer, 3, method, states);

Original file line number Diff line number Diff line change
@@ -361,19 +361,20 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa
control.awaitWarmdownReady();

// Wait for the result, handling timeouts
int interrupts = 0;
while (completed.size() < numThreads) {
try {
long waitFor = Math.max(TimeUnit.MILLISECONDS.toNanos(100), waitDeadline - System.nanoTime());
Future<BenchmarkTaskResult> fr = srv.poll(waitFor, TimeUnit.NANOSECONDS);
if (fr == null) {
// We are in the timeout mode now, kick all the still running threads.
out.print("(*interrupt*) ");
for (BenchmarkTask task : runners) {
Thread runner = task.runner;
if (runner != null) {
runner.interrupt();
}
}
interrupts++;
} else {
completed.add(fr);
}
@@ -382,6 +383,10 @@ public IterationResult runIteration(BenchmarkParams benchmarkParams, IterationPa
}
}

if (interrupts > 0) {
out.print("(benchmark timed out, interrupted " + interrupts + " times) ");
}

// Process the results: we get here after all worker threads have quit,
// either normally or abnormally. This means, Future.get() would never block.
long allOps = 0;
Loading