[concurrency-interest] VarHandle.setVolatile vs classical volatile write

Hans Boehm boehm at acm.org
Mon Aug 28 20:27:20 EDT 2017


Can someone explain why setRelease seems to be appreciably slower, when it
is the only one that should not need any kind of fence on x86, and hence
should be much faster? Am I misreading the results?

On Fri, Aug 25, 2017 at 10:02 AM, Paul Sandoz <paul.sandoz at oracle.com>
wrote:

>
> On 18 Aug 2017, at 13:58, Dávid Karnok <akarnokd at gmail.com> wrote:
>
> Thanks. I did a benchmark (https://gist.github.com/akarnokd/
> c0d606bd7e29d143ee82f2026898dbb5) and got the following results:
>
> i5 6440HQ, Windows 10 x64, Java 9b181, JMH 1.19
>
> Benchmark                       Mode  Cnt          Score         Error
>  Units
> VolatilePerf.getAndAdd         thrpt    5  117841308,999 ± 3940711,142
>  ops/s
> VolatilePerf.getAndSet         thrpt    5  118162019,136 ± 1349823,016
>  ops/s
> VolatilePerf.releaseGetAndAdd  thrpt    5  118688354,409 ±  642044,969
>  ops/s
> VolatilePerf.setRelease        thrpt    5  890890009,555 ± 4323041,380
>  ops/s
> VolatilePerf.setVolatile       thrpt    5  118419990,949 ±  793885,407
>  ops/s
>
>
> Being on Windows and on a Laptop usually yields some variance, but looks
> like there is practically minimal difference between the full barrier
> operations.
>
>
> Ok, good to know, thanks for dong that!
>
>
> Btw, thinking about XCHG and XADD, they have to provide the same strong
> volatile read and write as they both read and write something atomically. I
> would have thought XADD involving some ALU is detectably more costly but a
> 3 cycle addition is relatively small compared to a 22-45 cycle cache action.
>
>
> Yes, good point.
>
> Paul.
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170828/760cebb5/attachment.html>


More information about the Concurrency-interest mailing list