[concurrency-interest] ConcurrentHashMap footprint and contention improvements

Martin Buchholz martinrb at google.com
Fri Apr 15 10:33:27 EDT 2011


On Fri, Apr 15, 2011 at 03:29, Doug Lea <dl at cs.oswego.edu> wrote:
> On 04/14/11 21:13, Martin Buchholz wrote:
>>
>> I'm looking at the latest CHM.containsValue.
>>
>> Suppose the first traversal over the segments discovers no entries
>> (map apparently empty).  The intent appears to be to retry,
>
> Right; thanks! This exit check should read:
>
> diff -r1.102 ConcurrentHashMap.java
> 954c954
> <                 if (sum == last)
> ---
>>                 if (retries > 0 && sum == last)

Yes, this will prevent returning after a single unsuccessful
traversal, but ... it will still be possible (albeit unlikely) after
two.  The older code that used segment modcounts was more
robust/paranoid in the face of concurrently whack-a-mole-dodging
entries.

Personally, I'm OK with a weaker containsValue, but that's not
consistent with CHM tradition.

Martin



More information about the Concurrency-interest mailing list