RFR: 8338930: StringConcatFactory hardCoded string concatenation strategy [v4]
Shaojin Wen
duke at openjdk.org
Mon Aug 26 21:23:04 UTC 2024
On Mon, 26 Aug 2024 20:51:35 GMT, Shaojin Wen <duke at openjdk.org> wrote:
>> This is a follow-up to PR #20273, which improves performance when the number of parameters exceeds 20.
>>
>> When the number of parameters is large, the possibility of reuse will be lower, so we can use the static concat method and write the length and coder directly into the bytecode to solve the performance regression problem.
>
> Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains nine commits:
>
> - optimize for CompactStrings is off
> - Merge remote-tracking branch 'upstream/master' into optim_concat_factory_202408
>
> # Conflicts:
> # src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
> - add control flag `reuseThreshold`
> - Revert "Optimize the construction of MethodType and MethodTypeDesc to reduce memory allocation"
>
> This reverts commit 3bed7290f5cb987e86407f698fb0598f19d65628.
> - Optimize the construction of MethodType and MethodTypeDesc to reduce memory allocation
> - revert code style
> - from suggest
> - Update src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
>
> Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
> - support staticConcat
Below are the performance numbers I ran on a MacBook M1 Pro. The numbers show that when constants are hard-coded, performance is good even without forceinline. The default values of reuseThreshold and inlineThreshold can even be aggressively set to 4.
# fetch current version
git checkout a9fa264afd9fa625ef29357a7ca8559ce9c5fea4
# default non-args
make test TEST="micro:java.lang.StringConcat.concat6String"
# reuseThreshold=4 inlineThreshold=4
make test TEST="micro:java.lang.StringConcat.concat6String" MICRO="VM_OPTIONS=-Djava.lang.invoke.StringConcat.reuseThreshold=4 -Djava.lang.invoke.StringConcat.inlineThreshold=4"
# reuseThreshold=8 inlineThreshold=4
make test TEST="micro:java.lang.StringConcat.concat6String" MICRO="VM_OPTIONS=-Djava.lang.invoke.StringConcat.reuseThreshold=8 -Djava.lang.invoke.StringConcat.inlineThreshold=4"
# default non-args
Benchmark (intValue) Mode Cnt Score Error Units
StringConcat.concat6String 4711 avgt 15 19.329 ? 0.476 ns/op
# reuseThreshold=4 inlineThreshold=4
Benchmark (intValue) Mode Cnt Score Error Units
StringConcat.concat6String 4711 avgt 15 19.256 ? 0.296 ns/op
# reuseThreshold=8 inlineThreshold=4
Benchmark (intValue) Mode Cnt Score Error Units
StringConcat.concat6String 4711 avgt 15 24.714 ? 0.176 ns/op
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20675#issuecomment-2311118543
More information about the core-libs-dev
mailing list