RFR: 8311178: JMH tests don't scale well when sharing output buffers

Swati Sharma duke at openjdk.org
Tue Jul 11 08:07:13 UTC 2023


On Mon, 10 Jul 2023 16:07:44 GMT, John Jiang <jjiang at openjdk.org> wrote:

> Not review this PR, but just raise a question. Should a JMH test, at least in JDK repo, always uses `@State(Scope.Thread)`, even though it uses only one thread?
> 
> I just looked through those JMH tests, and found all of them, like the bellows, don't specify the number of threads via `@Threads`.
> 
> ```
> org/openjdk/bench/java/io/DataOutputStreamTest.java
> org/openjdk/bench/java/lang/ArrayCopyObject.java
> ```
> 
> I suppose the default number of threads is 1. Maybe the default value will be overridden via the commands when running these JMH tests in bulk (?)

Not always but state should be set to Thread level when the class variables are shared by multiple threads, also the variable scope should be set to non static. While running these benchmarks in multithreaded way, observed scaling issues as variables are shared but scope is set to benchmark level.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14746#issuecomment-1630347091


More information about the hotspot-compiler-dev mailing list