RFR: 8338930: StringConcatFactory hardCoded string concatenation strategy [v5]

Shaojin Wen duke at openjdk.org
Tue Aug 27 00:00:04 UTC 2024


On Mon, 26 Aug 2024 22:25:49 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 incrementally with two additional commits since the last revision:
> 
>  - reuseThreshold -> cacheThreshold
>  - Revert "optimize for CompactStrings is off"
>    
>    This reverts commit a9fa264afd9fa625ef29357a7ca8559ce9c5fea4.

Below are the performance numbers of different JVM startup options running on MacBook M1 Pro.

`reuseThreshold=4 inlineThreshold=4` performs better in the first round of warm-up.


make test TEST="micro:java.lang.StringConcat.concat6String" MICRO="VM_OPTIONS=-Djava.lang.invoke.StringConcat.reuseThreshold=8 -Djava.lang.invoke.StringConcat.inlineThreshold=8"

# Run progress: 0.00% complete, ETA 00:00:30
# Fork: 1 of 3
# Warmup Iteration   1: 21.933 ns/op
# Warmup Iteration   2: 21.426 ns/op
# Warmup Iteration   3: 19.380 ns/op
# Warmup Iteration   4: 19.363 ns/op
# Warmup Iteration   5: 20.380 ns/op
# Warmup Iteration   6: 20.261 ns/op
# Warmup Iteration   7: 19.596 ns/op
# Warmup Iteration   8: 20.263 ns/op
# Warmup Iteration   9: 18.877 ns/op
# Warmup Iteration  10: 19.192 ns/op
Iteration   1: 20.233 ns/op
Iteration   2: 18.969 ns/op
Iteration   3: 19.928 ns/op
Iteration   4: 19.917 ns/op
Iteration   5: 18.987 ns/op

# Run progress: 33.33% complete, ETA 00:00:20
# Fork: 2 of 3
# Warmup Iteration   1: 23.175 ns/op
# Warmup Iteration   2: 20.118 ns/op
# Warmup Iteration   3: 20.792 ns/op
# Warmup Iteration   4: 21.484 ns/op
# Warmup Iteration   5: 21.586 ns/op
# Warmup Iteration   6: 20.314 ns/op
# Warmup Iteration   7: 20.115 ns/op
# Warmup Iteration   8: 21.828 ns/op
# Warmup Iteration   9: 21.962 ns/op
# Warmup Iteration  10: 20.389 ns/op
Iteration   1: 20.517 ns/op
Iteration   2: 20.657 ns/op
Iteration   3: 20.371 ns/op
Iteration   4: 20.880 ns/op
Iteration   5: 20.377 ns/op

# Run progress: 66.67% complete, ETA 00:00:10
# Fork: 3 of 3
# Warmup Iteration   1: 23.821 ns/op
# Warmup Iteration   2: 20.281 ns/op
# Warmup Iteration   3: 21.580 ns/op
# Warmup Iteration   4: 20.035 ns/op
# Warmup Iteration   5: 19.159 ns/op
# Warmup Iteration   6: 19.914 ns/op
# Warmup Iteration   7: 18.688 ns/op
# Warmup Iteration   8: 18.882 ns/op
# Warmup Iteration   9: 19.639 ns/op
# Warmup Iteration  10: 18.985 ns/op
Iteration   1: 19.548 ns/op
Iteration   2: 19.060 ns/op
Iteration   3: 19.083 ns/op
Iteration   4: 20.074 ns/op
Iteration   5: 18.899 ns/op




make test TEST="micro:java.lang.StringConcat.concat6String" MICRO="VM_OPTIONS=-Djava.lang.invoke.StringConcat.reuseThreshold=4 -Djava.lang.invoke.StringConcat.inlineThreshold=4"

Running test 'micro:java.lang.StringConcat.concat6String'
# reuseThreshold=4 inlineThreshold=4

# Run progress: 0.00% complete, ETA 00:00:30
# Fork: 1 of 3
# Warmup Iteration   1: 22.131 ns/op
# Warmup Iteration   2: 20.265 ns/op
# Warmup Iteration   3: 20.431 ns/op
# Warmup Iteration   4: 19.408 ns/op
# Warmup Iteration   5: 20.723 ns/op
# Warmup Iteration   6: 20.073 ns/op
# Warmup Iteration   7: 19.341 ns/op
# Warmup Iteration   8: 20.285 ns/op
# Warmup Iteration   9: 19.997 ns/op
# Warmup Iteration  10: 19.217 ns/op
Iteration   1: 19.142 ns/op
Iteration   2: 20.158 ns/op
Iteration   3: 19.185 ns/op
Iteration   4: 19.236 ns/op
Iteration   5: 19.227 ns/op

# Run progress: 33.33% complete, ETA 00:00:20
# Fork: 2 of 3
# Warmup Iteration   1: 22.016 ns/op
# Warmup Iteration   2: 20.012 ns/op
# Warmup Iteration   3: 19.158 ns/op
# Warmup Iteration   4: 18.986 ns/op
# Warmup Iteration   5: 19.255 ns/op
# Warmup Iteration   6: 19.056 ns/op
# Warmup Iteration   7: 19.062 ns/op
# Warmup Iteration   8: 19.120 ns/op
# Warmup Iteration   9: 18.993 ns/op
# Warmup Iteration  10: 19.956 ns/op
Iteration   1: 19.190 ns/op
Iteration   2: 19.010 ns/op
Iteration   3: 19.534 ns/op
Iteration   4: 18.810 ns/op
Iteration   5: 20.023 ns/op

# Run progress: 66.67% complete, ETA 00:00:10
# Fork: 3 of 3
# Warmup Iteration   1: 22.407 ns/op
# Warmup Iteration   2: 19.742 ns/op
# Warmup Iteration   3: 20.294 ns/op
# Warmup Iteration   4: 20.348 ns/op
# Warmup Iteration   5: 19.787 ns/op
# Warmup Iteration   6: 19.931 ns/op
# Warmup Iteration   7: 19.206 ns/op
# Warmup Iteration   8: 19.205 ns/op
# Warmup Iteration   9: 20.156 ns/op
# Warmup Iteration  10: 19.244 ns/op
Iteration   1: 19.890 ns/op
Iteration   2: 19.013 ns/op
Iteration   3: 18.983 ns/op
Iteration   4: 18.966 ns/op
Iteration   5: 19.143 ns/op

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

PR Comment: https://git.openjdk.org/jdk/pull/20675#issuecomment-2311311154


More information about the core-libs-dev mailing list