Advice on how to use JMH for benchmarking an application that uses ExecutorService?
Aleksey Shipilev
aleksey.shipilev at oracle.com
Mon Feb 3 12:44:16 PST 2014
On 02/04/2014 12:36 AM, Behrooz N wrote:
> I have started to use JMH with @BenchmarkMode(SampleTime). The question
> rose to me when at predictable runs of the benchmark, the runner seems to
> get stuck at some iteration. I tried to use jstack to identity any possible
> deadlock but it revealed nothing. This behavior was much more recurrent
> when using Throughput mode.
Are you shutting down the executor? The non-daemon threads will prevent
JVM to exit, and so forked VM will never return, and the run will be
stalled. Hence the alternative: daemon threads.
It's hard to tell what is wrong otherwise. More logs and jstack traces
needed to hypothesize what could be wrong.
> So, I am asking for advice for the configurations on memory, fork
> configuration, threads, iteration sync or any example document that have
> hints on this.
SampleTime is the best suitor for the job. There is no other strong
requirements per se, but choose the options wisely :) The only other
thing I can think of is modeling the think-time between requests, e.g.:
http://hg.openjdk.java.net/code-tools/jmh/file/f2e982b7c51b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java
-Aleksey.
More information about the jmh-dev
mailing list