RFR: 8301958: Avoid Arrays.copyOfRange overhead in java.lang.String [v5]
Claes Redestad
redestad at openjdk.org
Tue Feb 7 22:47:45 UTC 2023
On Tue, 7 Feb 2023 19:10:08 GMT, Francesco Nigro <duke at openjdk.org> wrote:
>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>>
>> copyrights
>
> Thanks @cl4es to look into this!
@franz1981 idea seems to apply nicely here, and going back and applying it to `Arrays.copyOfRange` end up on top for the common case where `copyOfRange` copies the entire range:
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
We might still benefit for some cases to specialize a `copyBytes` method, but this solution might help more cases. If others agree I might take a step back and apply this optimization to all the `copyOfRange` methods and add some microbenchmarking to verify this more widely.
-------------
PR: https://git.openjdk.org/jdk/pull/12453
More information about the core-libs-dev
mailing list