RFR: 8371164: ArrayList.addAll() optimizations [v2]

jengebr duke at openjdk.org
Tue Nov 4 21:19:48 UTC 2025


On Tue, 4 Nov 2025 20:51:41 GMT, Johannes Döbler <duke at openjdk.org> wrote:

>> jengebr has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Adding direct unit tests, minor revisions to optimizations
>
> test/micro/org/openjdk/bench/java/util/ArrayListBulkOpsBenchmark.java line 63:
> 
>> 61: public class ArrayListBulkOpsBenchmark {
>> 62:     @Param({"0", "1", "5", "75"})
>> 63:     int size;
> 
> The size parameter is used twice:
> - to construct a collection of varying sizes which is to be added
> - as initialCapacity of the receiving ArrayList
> Can this impact the benchmark results? Maybe introduce two independent params.

This is deliberate, ensuring that the add operation does not require growing the internal array.  Growth isn't affected by the change and eliminating it reduces a key variable from the measurements.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2492072181


More information about the core-libs-dev mailing list