[concurrency-interest] Using Atomic*FieldUpdater to remove indirection
ariel at weisberg.ws
Wed Feb 13 16:45:42 EST 2013
I have two use cases in mind.
I have some COW* data structures that use AtomicReference internally
for example COWNavigableSet. Using AtomicReference means there is an
extra indirection for every lookup.
The other use case is a field that tracks the last time a message
was received from a host. There is a single thread that updates the
field every time a message is delivered and multiple threads read the
field every time they send a message to that host.
In the last message time tracking use case there will always be a
coherence operation for the cache line containing the value tracking
the last message time. I suppose it doesn't really matter if the other
fields in that class are on the same line because the number of
coherence operations remains the same. If there were a get equivalent
of lazySet that would be nice.
On Wed, Feb 13, 2013, at 03:51 PM, Vitaly Davidovich wrote:
Can you elaborate a bit? Do you mean using AtomicInteger (as an
example) instead of an int field inside a class? If so, I'd
personally pad out the class with filler fields to avoid false
sharing - there's no guarantee that the indirection via AtomicXXX
will put memory far apart; padding gives you a bit more control
Sent from my phone
On Feb 13, 2013 3:44 PM, "Ariel Weisberg" <ariel at weisberg.ws> wrote:
Does it make sense to use Atomic*FieldUpdater to remove the
overhead of an AtomicLong and AtomicReference? Similarly, does it
sense to use Atomic* to create indirection in order to avoid false
Concurrency-interest mailing list
Concurrency-interest at cs.oswego.edu
4. mailto:ariel at weisberg.ws
5. mailto:Concurrency-interest at cs.oswego.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest