Thread number aware benchmarks and groups

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Nov 18 02:52:24 PST 2013


On 11/14/2013 06:54 PM, Nitsan Wakart wrote:
> Hi,
> I'm using JMH to benchmark producer/consumer queues and would like to be able to split the producer consumers into groups such that the size of the 2 groups is the total number of threads. I.e:
> @GenerateMicroBenchmark
> 
> @Group("group")
> @Threads(N/2)
> public void offer(){
> ...
> }
> @GenerateMicroBenchmark
> 
> @Group("group")
> @Threads(N/2)
> public void poll(){
> ...
> }
> I'm happy to jump in and implement just wanted to check feasibility/road map/objections before I do.
> Is there an alternative people use at the moment to achieve same effect?

Sorry for late reply. There are two caveats:

 a) The thread distribution between groups is static, and reflected in
the generated code. It is not possible to change the distribution of
threads among the methods after the benchmark is compiled. (This should
be changed as soon as we find the proper dynamic substitute to the
static scheme we have now).

 b) Defining the expressions in the annotations is uber-hard, because
annotations normally accept constants only. You *may* try to put the
String expression there hoping the infra will evaluate it for you, but I
would rather see people use Java API for customizing the workloads like
that.

-Aleksey.



More information about the jmh-dev mailing list