[jmm-dev] @Contended

Andrew Haley aph at redhat.com
Wed Apr 27 13:07:42 UTC 2016


On 04/27/2016 01:16 PM, Aleksey Shipilev wrote:
> On 04/27/2016 03:11 PM, Andrew Haley wrote:
>> I wonder if it is worth padding AtomicIntegers.
> 
> Nope. Alas, @Contended is class-wide, and there are lots of cases where
> people are using AtomicIntegers without expecting them to take 10x more
> memory all of the sudden.

Yea, and without value types there's no easy way for users to pad them.

On most of the arches I use AtomicIntegers are two xwords in size;
I guess they'd have to grow to eight xwords for they "typical" cache
line size.  Which is a big bump.

BTW, this is something that ObjectLayout may be good for.
(http://objectlayout.org/)

> With all the attention false sharing gets, it
> sensibly affects specific classes in specific kind of applications only.

I'm sure that's true, but everybody hates false sharing because it's
so unpredictable in a garbage-collected language.  Even if it's never
happened to them.

Andrew.



More information about the jmm-dev mailing list