> Please review this small benchmark fix. > > Running `ThreadStartJoin` with two workers can fail: `java -jar > benchmarks.jar -t 2 ThreadStartJoin` > > > # Warmup Iteration 1: <failure> > > java.lang.IllegalThreadStateException > at java.base/java.lang.Thread.start(Thread.java:1494) > at > org.openjdk.bench.java.lang.ThreadStartJoin.test(ThreadStartJoin.java:62) > at > org.openjdk.bench.java.lang.jmh_generated.ThreadStartJoin_test_jmhTest.test_avgt_jmhStub(ThreadStartJoin_test_jmhTest.java:238) > at > org.openjdk.bench.java.lang.jmh_generated.ThreadStartJoin_test_jmhTest.test_AverageTime(ThreadStartJoin_test_jmhTest.java:177) > at > java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) > > > **Fix:** Change `Scope.Benchmark` to `Scope.Thread` so each worker has its > own thread array. > > The test is meant to measure the cost of creating, starting, and waiting for > a batch of threads to finish, not having multiple workers operate on the same > thread array. So this looks like a low-risk change that keeps the benchmark's > original intent. > > **Testing:** > - ThreadStartJoin: 1/2/4 workers passed, using the default CPU count and > `-XX:ActiveProcessorCount=1` and `2`. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Yunbo Zhang has updated the pull request incrementally with one additional commit since the last revision: 8350907: [JMH] test ThreadStartJoin failed for 2 threads config Require a single JMH worker in trial setup and restore benchmark-scoped state, leaving the measured workload unchanged. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/33239/files - new: https://git.openjdk.org/jdk/pull/33239/files/8ce5ff27..f5945d14 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=33239&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33239&range=00-01 Stats: 12 lines in 1 file changed: 11 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/33239.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33239/head:pull/33239 PR: https://git.openjdk.org/jdk/pull/33239
