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

David Schlosnagle duke at openjdk.org
Sat Feb 18 01:43:24 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.

Marked as reviewed by schlosna at github.com (no known OpenJDK username).

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

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


More information about the core-libs-dev mailing list