JMH benchmarks, loop unrolling and branch-prediction

Francesco Nigro nigro.fra at gmail.com
Fri Jan 10 18:02:43 UTC 2020


Follow-up of the previous email: https://github.com/netty/netty/pull/9942
I've produced a 1.0 version of the same benchmark, but still not convinced
if it worths randomize the choice of the next input from and array of inputs
to make the life of the branch predictor less easy.

Il giorno ven 10 gen 2020 alle ore 11:59 Francesco Nigro <
nigro.fra at gmail.com> ha scritto:

> 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