Single Consumer Multiple Producers Benchmark
Ron Pressler
ron at paralleluniverse.co
Wed Dec 4 09:36:11 PST 2013
Basically I want to benchmark the queue for different numbers of producer threads. Say 1, 2, 5, and 10. In each case I’ll need exactly one consumer thread.
Maybe the -tg flag is what I’m looking for. Can you explain exactly how it works? How do you control what is considered the “first” group or the “second” group?
On December 4, 2013 at 7:30:12 PM, Aleksey Shipilev (aleksey.shipilev at oracle.com) wrote:
Hi,
On 12/04/2013 09:05 PM, Ron Pressler wrote:
> Say I want to benchmark a queue implementation with multiple
> producers and a single consumer. I can limit the consumer’s method
> with @GroupThreads(1), but I want the producer subgroup to use all
> remaining available threads. Is that possible?
Depends on what you mean by "remaining available".
Basically, you have two options:
a) If you want to juggle the thread subgroup distribution, make the
@Group out of two methods, and play with "-tg 1,${X}" on the command
line, where $X is the number of threads you want in the second subgroup.
b) If you want to autodetect the available CPU count on your machine,
then it starts to get a bit trickier. You need to use Java API to push
that value into the workload, something like this:
int maxThreads = Runtime.getRuntime().availableProcessors();
Options opts = new OptionsBuilder()
.include(".*")
.threadGroups(1, maxThreads - 1)
.build();
RunResult runResult = new Runner(opts).runSingle();
The complete example is available here [1].
In both cases, the total number of threads will automatically adjust to
have a full group.
-Aleksey.
[1]
http://hg.openjdk.java.net/code-tools/jmh/file/f39c77f5b84a/jmh-api-samples/src/main/java/org/openjdk/jmh/SimpleTest.java
More information about the jmh-dev
mailing list