RFR [8011215] optimization of CopyOnWriteArrayList.addIfAbsent()

Ivan Gerasimov ivan.gerasimov at oracle.com
Tue Apr 2 23:28:29 UTC 2013


Thank you, Louis.

Yes, you're probably right.
I might want to get familiar with caliper mentioned earlier, or 
something else like that.
However, I'd like to note that in the tests exactly the same amount of 
allocations were made for both versions of code.
The difference in the code is around these allocations.

On 03.04.2013 2:36, Louis Wasserman wrote:
> I would be deeply suspicious of benchmarks that naive, especially for 
> benchmarks like this that involve lots of allocation -- you're most 
> likely benchmarking the GC, not the actual operation.
>
>
> On Tue, Apr 2, 2013 at 3:33 PM, Ivan Gerasimov 
> <ivan.gerasimov at oracle.com <mailto:ivan.gerasimov at oracle.com>> wrote:
>
>
>     On 03.04.2013 1:17, Martin Buchholz wrote:
>
>         Have you benchmarked the case where the element is never present?
>
>     That's the only case I've tested.
>     If the element were in the array, my code would obviously win.
>
>
>         (with the usual caveats about micro-benchmarking - perhaps use
>         google caliper?)
>
>     The tests I wrote are quite simple - they just run a code snippet
>     for several hundreds of times.
>     I've just sent and archive with the tests in reply to the other
>     message in the thread.
>
>
>
>         On Tue, Apr 2, 2013 at 2:11 PM, Ivan Gerasimov
>         <ivan.gerasimov at oracle.com <mailto:ivan.gerasimov at oracle.com>
>         <mailto:ivan.gerasimov at oracle.com
>         <mailto:ivan.gerasimov at oracle.com>>> wrote:
>
>
>             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.
>
>
>
>
>
> -- 
> Louis Wasserman




More information about the core-libs-dev mailing list