[concurrency-interest] Software Transactional Memory

Doug Lea dl at cs.oswego.edu
Mon Mar 26 06:43:05 EDT 2007


Joseph Seigh wrote:
> 
> 
> Question about ConcurrentLinkedQueue.  It uses AtomicReferenceFieldUpdater
> rather than AtomicReference.  Why is that?  T

The two choices have different tradeoffs. Using fieldUpdaters does
have more per-call overhead, but in principle most of it
is optimizable away, and on some platforms and some contexts,
it often is. Using a separate AtomicReference in essence doubles
the length of a list (every second indirection is just a
pointer holding the real pointer). And for small nodes as used
here, nearly doubles the footprint -- even a one-field object
has object header etc overhead, and increases GC overhead.
All in all, using fieldUpdaters in this case is the best
choice, even though on some programs/platforms it might on average
be a  little slower (and on others faster).

-Doug




More information about the Concurrency-interest mailing list