RFR: 8301958: Reduce Arrays.copyOf/-Range overheads [v8]

Claes Redestad redestad at openjdk.org
Wed Feb 8 10:44:12 UTC 2023


> This patch adds special-cases to `Arrays.copyOf` and `Arrays.copyOfRange` to clone arrays when `newLength` or range inputs span the input array. This helps eliminate range checks and has been verified to help various String operations. Example:
> 
> Baseline
> 
> Benchmark                                            (size)  Mode  Cnt   Score   Error  Units
> StringConstructor.newStringFromArray                      7  avgt   15  16.817 ± 0.369  ns/op
> StringConstructor.newStringFromArrayWithCharset           7  avgt   15  16.866 ± 0.449  ns/op
> StringConstructor.newStringFromArrayWithCharsetName       7  avgt   15  22.198 ± 0.396  ns/op
> 
> Patch: 
> 
> Benchmark                                            (size)  Mode  Cnt   Score   Error  Units
> StringConstructor.newStringFromArray                      7  avgt   15  14.666 ± 0.336  ns/op
> StringConstructor.newStringFromArrayWithCharset           7  avgt   15  14.582 ± 0.288  ns/op
> StringConstructor.newStringFromArrayWithCharsetName       7  avgt   15  20.339 ± 0.328  ns/op

Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:

  Err on the side of copyOf

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/12453/files
  - new: https://git.openjdk.org/jdk/pull/12453/files/c906c730..85b50169

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12453&range=07
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12453&range=06-07

  Stats: 90 lines in 1 file changed: 56 ins; 23 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/12453.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12453/head:pull/12453

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


More information about the core-libs-dev mailing list