[concurrency-interest] Reference Collections

Doug Lea dl at cs.oswego.edu
Wed Jan 4 14:24:06 EST 2012


On 01/04/12 13:32, Vitaly Davidovich wrote:
> Volatile read will be cheaper but if other cores are constantly writing to the
> shared memory that's being read then throughput will degrade - basically even
> normal stores/loads of shared locations won't scale under heavy writing.  My
> only point was that CAS doesn't have to be 10s of cycles as you said (and it's
> getting cheaper with each new generation, except sandy bridge seems to have
> gotten worse than nehalem)

This is my experience as well. A CAS that almost never fails is sometimes
even cheaper than a volatile write on i7-Nehalem. It is more
expensive on SandyBridge/NehalemEX and recent AMDs but still not worth
spending more than a couple of cycles trying to avoid. Nathan's advice to read
rather than CAS when possible is a good example of when it is worth
avoiding, but beyond that there are diminishing returns. Of course,
avoiding unnecessary writes of any form is always a good idea.

These days, memory contention (mainly false-sharing-style cache
contention, plus NUMA effects) is a far more serious performance
issue than CAS contention per se, especially on multisocketed machines.

I've been working on a set of improvements
to a bunch of j.u.c classes that address this. Stay tuned.
Currently, the only one committed to our CVS is a preliminary
version of overhauled Exchanger. (Exchangers are not commonly
used, but they provide an ideal setting for evaluating new
performance enhancement algorithms, since they are subject to
extreme contention, lock-free data-transfer, and blocking;
all of which are found in more commonly used classes).

-Doug



More information about the Concurrency-interest mailing list