[concurrency-interest] RFR  optimization of CopyOnWriteArrayList.addIfAbsent()
ivan.gerasimov at oracle.com
Tue Apr 2 17:11:58 EDT 2013
> Thanks for this change. There is a tradeoff here. If the element is
> never present, then the older code might be a little faster, because
> we can avoid re-traversing the array. Otherwise, the new code is better.
I've done a little testing on my side.
I used Integer as an underlying type and set length of the array to the
values from 1 to 100.
My code shows a little performance gain - approximately 9%.
I understand it may not be there for all cases, but at least for some
cases it is there.
> I prefer it your way (I hate unneeded allocation), but the code was
> intentionally written the other way. Let's hear from Doug...
> On Tue, Apr 2, 2013 at 1:38 PM, Ivan Gerasimov
> <ivan.gerasimov at oracle.com <mailto:ivan.gerasimov at oracle.com>> wrote:
>> Please review my proposal for the
>> CopyOnWriteArrayList.addIfAbsent() method optimization.
>> This URL is not readable by external reviewers.
> The webrev has been copied here:
>> The "master" version of CopyOnWriteArrayList is here:
> Thanks for the link!
> I see that the code in the master version is identical to the one
> I've been working on.
> So the optimization still could be applied.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest