Usage of Blackhole in a loop distorts benchmark results
Aleksey Shipilev
shade at redhat.com
Wed Jan 17 11:00:23 UTC 2018
On 01/17/2018 11:40 AM, Nitsan Wakart wrote:
> See this post: http://psy-lob-saw.blogspot.com/2014/08/the-volatile-read-suprise.htmlAnd the
> current BH code:
> http://hg.openjdk.java.net/code-tools/jmh/file/a0c4f5e23278/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java#l306In
> summary, blackhole carries semantics of calling into an NOT-inlined method and a memory barrier.
> This is arguably heavy handed, but consider the formidable foe (the compiler) we are trying to
> fool with it. We are trying to prevent DCE due to unsunk values. It works, yay!The benchmarks you
> compare with/out blackhole are therefore very different in meaning, and as such different results
> are not surprising.
What Nitsan said, and also this is a tangential topic for JMHSample_34_SafeLooping:
http://hg.openjdk.java.net/code-tools/jmh/file/a0c4f5e23278/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java
Thanks,
-Aleksey
More information about the jmh-dev
mailing list