On Tue, 20 Oct 2026 15:45:20 GMT, Yunbo Zhang <[email protected]> wrote:
>> 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:** >> >> Require a single JMH worker in `@Setup(Level.Trial)`, leaving the measured >> workload unchanged. >> >> **Testing:** >> - Default configuration and `-t 1`: passed. >> - `-t 2` and `-t 4`: rejected during setup with a clear error message. >> >> --------- >> - [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. I think individual benchmarks should be able to control the number of threads that can be used. This benchmark seems inherently single-threaded so it should be able to enforce that and prevent the user from setting -t in a way that makes no sense. That is what the current patch does. If other benchmarks need the same fix then so be it, but it isn't really for the current PR to examine every single benchmark. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33239#issuecomment-6406158045
