[concurrency-interest] RFR  optimization of CopyOnWriteArrayList.addIfAbsent()
martinrb at google.com
Tue Apr 2 18:47:54 EDT 2013
On Tue, Apr 2, 2013 at 3:45 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com>wrote:
> Thank you, Ulf!
> maybe the old code wins for looong arrays, so there could be a threshold
>> to decide between old and new code:
> I've modified the benchmark code to test arrays with 90'000 to 100'000
> elements. (Previously was testing 1 to 100 elements.)
> The performance gain turns out to be even more significant.
> On my machine tests show that with that many elements the new code runs
> 40% faster.
> Honestly, I didn't expect that. I thought my code might be a bit slower
> and hoped that not much slower.
Yeah, that's a bit surprising. Perhaps because you're avoiding the branch
of testing object for null on each iteration?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest