[External] : RFD: Specializing ArrayDeque copy constructor for ArrayDeque (and possibly ArrayList)
Chen Liang
chen.l.liang at oracle.com
Wed Feb 25 15:31:46 UTC 2026
Hello Eirik, this is a general problem caused by type profile pollution in bytecode of these constructors so that virtual calls become slow, fully virtual calls. I do not think this site is used frequent enough that warrants a monkey patch like that in ArrayList; such monkey patches will be removed in the future shall the JVM provide a better specialization solution.
If you want to learn more about how type profile pollution works, feel free to check out the patch for https://bugs.openjdk.org/browse/JDK-8366424, where there's a benchmark that explains how all these pollutions happen.
Regards,
Chen Liang
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org> on behalf of Eirik Bjørsnøs <eirbjo at gmail.com>
Sent: Wednesday, February 25, 2026 9:08 AM
To: core-libs-dev <core-libs-dev at openjdk.org>
Subject: [External] : RFD: Specializing ArrayDeque copy constructor for ArrayDeque (and possibly ArrayList)
Hi, While looking into ArrayDeque: : addElements recently, I noticed that the copy constructor ArrayDeque(Collection) does not specialize for an ArrayDeque being passed in a similar fashion to what ArrayList does. By utilizing the ArrayListBulkOpsBenchmark
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/ACWV5N9M2RV99hQ!Op20OCpm1CSlHTAAv166s1TUpoWxmKY80Fp0sfkRpwj3IiVbBFywyh2YCoQcpFBR61255FrMKi3x_VMgCQbiIMhr3epTsIh7u6f_8RvkbTHciw10cvaXUBuMqLQ0-59vRQ$>
Report Suspicious
ZjQcmQRYFpfptBannerEnd
Hi,
While looking into ArrayDeque::addElements recently, I noticed that the copy constructor ArrayDeque(Collection) does not specialize for an ArrayDeque being passed in a similar fashion to what ArrayList does.
By utilizing the ArrayListBulkOpsBenchmark and adopting it for ArrayDeque, I was able to test the performance impact of specializing ArrayDeque(Collection) for ArrayDeque.
Results show a reduction in time/op ranging from 30% (1 element) to 75% (75 elements).
I also experimented with a similar specialization for ArrayList which shows promising results, up to 50% faster for lists of size 75.
However, there are many collections in the JDK and which combinations to specialize for is not obvious. Is further exploration here worthwhile?
Cheers,
Eirik.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260225/703b8ef9/attachment.htm>
More information about the core-libs-dev
mailing list