[concurrency-interest] Using Atomic*FieldUpdater to remove indirection

Chris Dennis cdennis at terracottatech.com
Thu Feb 14 11:15:16 EST 2013


My understanding is that doing that is not technically (per the JDK spec) safe.  The updaters don't guarantee atomicity of their changes with respect to other mutations.  On Hotspot I think you can only see this behavior for AtomicLongFieldUpdater when the underlying hardware lacks an 8 byte compare-and-swap (which obviously makes sense).

On Feb 13, 2013, at 10:37 PM, Aaron Grunthal wrote:

> Btw, Atomic*Updaters are not entirely equivalent to raw volatile/CAS accesses due to a bunch of security checking they do. Especially when security domains are used or the Updater's target class has subclasses then it has to do some checks that the JVM cannot optimize away. So if every ounce of performance counts you probably should do volatile reads and writes to the field handled by the updater directly and only use it for CAS. And as last resort there's also Unsafe, but there usually are bigger fish to fry before you get to that point.
> 
> On 13.02.2013 21:41, Ariel Weisberg wrote:
>> Hi,
>> 
>> Does it make sense to use Atomic*FieldUpdater to remove the indirection
>> overhead of an AtomicLong and AtomicReference? Similarly, does it make
>> sense to use Atomic* to create indirection in order to avoid false
>> sharing?
>> 
>> Thanks,
>> Ariel
>> _______________________________________________
>> Concurrency-interest mailing list
>> Concurrency-interest at cs.oswego.edu
>> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>> 
> 
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest




More information about the Concurrency-interest mailing list