JMH benchmarks, loop unrolling and branch-prediction

Francesco Nigro nigro.fra at gmail.com
Fri Jan 10 10:59:46 UTC 2020


Hi!

I've produced this benchmark:
https://github.com/franz1981/netty/blob/7c3513f12230bf0f46a48856922209934ba30987/microbench/src/main/java/io/netty/handler/codec/http/DecodeHexBenchmark.java

And I'm looking this JMH sample:
https://hg.openjdk.java.net/code-tools/jmh/file/c434f013bc2e/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_36_BranchPrediction.java

And I've received a comment from Nitsan Wakart on
https://github.com/netty/netty/pull/9896#discussion_r360254463

TLDR:
I would like to fix the benchmark to not make it too friendly with the
common strategies used by the branch predictors, but still make it produce
reliable numbers to analyze the different benchmarked methods: any
suggestions on how to do that correctly?

I hope that's the right place to ask this question, although is not
directly related to the tool, but more on use it correctly.

Thanks,
Franz


More information about the jmh-dev mailing list