RFR: 8371164: ArrayList.addAll() optimizations

jengebr duke at openjdk.org
Tue Nov 4 18:41:37 UTC 2025


On Mon, 3 Nov 2025 22:58:04 GMT, Chen Liang <liach at openjdk.org> wrote:

> I actually wonder if the ArrayList.class path reuses `Object[] a = c.toArray();` and `int numNew = a.length;`, we are still going to see a similar improvement - I wonder if the bottleneck is the lack of polymorphic inlining alone, or if an array copy with a size trim would hamper C2 too.

One bottleneck being addressed is the intermediate array creation - gc profiling confirms that exists and is a significant impact.  I don't have data showing the presence or absence of other bottlenecks, although the performance of the de-duplicated code suggests that change introduced a side effect.  The memory savings were still present so I speculate the change introduced a new bottleneck.

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

PR Comment: https://git.openjdk.org/jdk/pull/28116#issuecomment-3487518767


More information about the core-libs-dev mailing list