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.

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

Commit messages:
 - Examine arraycopy vs clone

Changes: https://git.openjdk.org/jdk/pull/12613/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12613&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8302315
  Stats: 163 lines in 2 files changed: 92 ins; 55 del; 16 mod
  Patch: https://git.openjdk.org/jdk/pull/12613.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12613/head:pull/12613

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

Reply via email to