Should I run JMH benchmarks with '-server' option

588 views Asked by At

I am using JMH, an OpenJDK microbenchmark tool. The build process creates microbenchmarks.jar that I invoke with java -jar and passing jar name and JMH arguments.

I wonder should we run the benchmarks with -server option and why?

In other words, should I run my benchmark with:

java -server -jar microbenchmarks.jar ...(jmh args)
2

There are 2 answers

0
Aleksey Shipilev On BEST ANSWER

Well, it depends on what you are trying to measure. In most cases, the default JVM mode on the machine is what you are after to replicate the same conditions which the ordinary Java application will encounter.

Hence, we usually don't add -server to benchmark runs, because on most machines the ergonomics itself implicitly selects it, see Server Class Machine Detection.

1
Leeor On

That entirely depends on what you want to benchmark - you should use that option if you want to measure how the system would behave when running server oriented workloads, using server JVM characteristics

see also - What is JVM -server parameter? , indicating that the -server switch also performs better JITting.