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

2023-02-18 Thread Claes Redestad
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad  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.

Thanks for reviewing

-

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


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

2023-02-18 Thread Alan Bateman
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad  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 alanb (Reviewer).

-

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


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

2023-02-17 Thread David Schlosnagle
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad  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 schlo...@github.com (no known OpenJDK username).

-

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


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

2023-02-17 Thread Claes Redestad
On Fri, 17 Feb 2023 09:58:54 GMT, Claes Redestad  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.

osx-aarch64:

Benchmark (size)  Mode  CntScore   Error  Units
ArrayClone.byteArraycopy   0  avgt   159,517 ± 1,272  ns/op
ArrayClone.byteArraycopy  10  avgt   155,933 ± 0,314  ns/op
ArrayClone.byteArraycopy 100  avgt   154,802 ± 0,234  ns/op
ArrayClone.byteArraycopy1000  avgt   15   24,671 ± 0,437  ns/op
ArrayClone.byteClone   0  avgt   152,417 ± 0,016  ns/op
ArrayClone.byteClone  10  avgt   152,924 ± 0,027  ns/op
ArrayClone.byteClone 100  avgt   154,563 ± 0,050  ns/op
ArrayClone.byteClone1000  avgt   15   24,737 ± 0,262  ns/op
ArrayClone.intArraycopy0  avgt   158,156 ± 2,148  ns/op
ArrayClone.intArraycopy   10  avgt   153,646 ± 0,025  ns/op
ArrayClone.intArraycopy  100  avgt   15   11,430 ± 0,087  ns/op
ArrayClone.intArraycopy 1000  avgt   15  106,174 ± 0,721  ns/op
ArrayClone.intClone0  avgt   152,455 ± 0,159  ns/op
ArrayClone.intClone   10  avgt   153,621 ± 0,013  ns/op
ArrayClone.intClone  100  avgt   15   11,648 ± 0,454  ns/op
ArrayClone.intClone 1000  avgt   15  106,469 ± 1,295  ns/op


linux-x64, sandybridge, avx2:

Benchmark (size)  Mode  CntScoreError  Units
ArrayClone.byteArraycopy   0  avgt   153.321 ±  0.194  ns/op
ArrayClone.byteArraycopy  10  avgt   156.953 ±  0.329  ns/op
ArrayClone.byteArraycopy 100  avgt   15   13.490 ±  0.595  ns/op
ArrayClone.byteArraycopy1000  avgt   15  150.201 ±  3.451  ns/op
ArrayClone.byteClone   0  avgt   155.431 ±  0.252  ns/op
ArrayClone.byteClone  10  avgt   156.370 ±  0.329  ns/op
ArrayClone.byteClone 100  avgt   15   13.561 ±  0.633  ns/op
ArrayClone.byteClone1000  avgt   15  150.300 ±  5.318  ns/op
ArrayClone.intArraycopy0  avgt   153.297 ±  0.226  ns/op
ArrayClone.intArraycopy   10  avgt   157.171 ±  0.354  ns/op
ArrayClone.intArraycopy  100  avgt   15   60.863 ±  1.580  ns/op
ArrayClone.intArraycopy 1000  avgt   15  557.770 ± 15.107  ns/op
ArrayClone.intClone0  avgt   155.373 ±  0.225  ns/op
ArrayClone.intClone   10  avgt   156.965 ±  0.293  ns/op
ArrayClone.intClone  100  avgt   15   61.696 ±  1.983  ns/op
ArrayClone.intClone 1000  avgt   15  552.809 ± 14.358  ns/op

-

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


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

2023-02-17 Thread Claes Redestad
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