RFR: 8276054: JMH benchmarks for Fences

Claes Redestad redestad at openjdk.java.net
Wed Oct 27 16:35:10 UTC 2021


On Wed, 27 Oct 2021 12:11:37 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> While working on JDK-8252990, I realized there are no microbenchmarks for Fences. I would be good to add some. While technically we can benchmark `Unsafe` directly, I instead chose to use the public API, `VarHandles`, as this captures the real-world uses too.
> 
> Sample output for `make test TEST=micro:vm.fences` on `x86_64`:
> 
> 
> Benchmark                      Mode  Cnt  Score    Error  Units
> Multiple.acquire               avgt    9  0.408 ±  0.005  ns/op
> Multiple.full                  avgt    9  4.694 ±  0.003  ns/op
> Multiple.plain                 avgt    9  0.407 ±  0.004  ns/op
> Multiple.release               avgt    9  0.407 ±  0.003  ns/op
> Multiple.storeStore            avgt    9  0.409 ±  0.006  ns/op
> MultipleWithLoads.acquire      avgt    9  4.600 ±  0.002  ns/op
> MultipleWithLoads.full         avgt    9  8.322 ±  0.003  ns/op
> MultipleWithLoads.plain        avgt    9  4.328 ±  0.001  ns/op
> MultipleWithLoads.release      avgt    9  4.600 ±  0.002  ns/op
> MultipleWithLoads.storeStore   avgt    9  4.600 ±  0.002  ns/op
> MultipleWithStores.acquire     avgt    9  0.812 ±  0.001  ns/op
> MultipleWithStores.full        avgt    9  5.291 ±  0.001  ns/op
> MultipleWithStores.plain       avgt    9  0.812 ±  0.001  ns/op
> MultipleWithStores.release     avgt    9  0.812 ±  0.001  ns/op
> MultipleWithStores.storeStore  avgt    9  0.812 ±  0.001  ns/op
> SafePublishing.plain           avgt    9  6.378 ±  0.011  ns/op
> SafePublishing.release         avgt    9  6.368 ±  0.010  ns/op
> SafePublishing.storeStore      avgt    9  6.376 ±  0.013  ns/op
> Single.acquireFence            avgt    9  0.410 ±  0.009  ns/op
> Single.fullFence               avgt    9  4.689 ±  0.002  ns/op
> Single.plain                   avgt    9  0.409 ±  0.010  ns/op
> Single.releaseFence            avgt    9  0.410 ±  0.006  ns/op
> Single.storeStoreFence         avgt    9  0.410 ±  0.009  ns/op

Benchmarks looks good. 

I'm surprised the build handles omitting the `org.openjdk.bench` package prefix. I don't particularly mind either way (and maybe removing this prefix would be an overall win), but I think we should keep it consistent for now and use `package org.openjdk.bench...`.

-------------

Marked as reviewed by redestad (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/6138


More information about the hotspot-dev mailing list