Integrated: 8302315: Examine cost of clone of primitive arrays compared to arraycopy

Claes Redestad redestad at openjdk.org
Sat Feb 18 15:21:33 UTC 2023


On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> During work on #12453 @schlosna reported that `array.clone()` might underperform `System.arraycopy` in microbenchmarks and I opted to go with `arraycopy` throughout while investigating.
> 
> Testing on x86 (SandyBridge, AVX2) I observe no difference at all between the setups. On aarch the only difference I can observe is that arraycopy seem curiously slow for input size = 0, otherwise no statistically significant difference. All tests ran on builds from JDK mainline and 21-b9.
> 
> Since the reported difference was small and mostly visible on very large arrays I conclude that the maintainability win we get from using `clone()` is preferable. I've added the microbenchmark provided by @schlosna here.

This pull request has now been integrated.

Changeset: d6716d2e
Author:    Claes Redestad <redestad at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/d6716d2e5471ee794df8833430dd3171b565f78e
Stats:     163 lines in 2 files changed: 92 ins; 55 del; 16 mod

8302315: Examine cost of clone of primitive arrays compared to arraycopy

Reviewed-by: alanb

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

PR: https://git.openjdk.org/jdk/pull/12613


More information about the core-libs-dev mailing list