RFR: 8338930: StringConcatFactory static string concatenation strategy
Shaojin Wen
duke at openjdk.org
Sun Aug 25 04:33:38 UTC 2024
On Thu, 22 Aug 2024 11:50:02 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.
Below are the performance numbers on a MacBook M1 Pro. When the number of parameters is greater than 16, the performance is significantly improved.
## Script
# baseline
git checkout 6644dd33f6f4b440105d84ef187a0ff6b1d60827
make test TEST="micro:java.lang.StringConcat."
# current
git checkout a2465a0e6011c4433833c5088ebcb5d56c6a5587
make test TEST="micro:java.lang.StringConcat."
## Performance Numbers
-# baseline
-Benchmark (intValue) Mode Cnt Score Error Units
-StringConcat.concat123String 4711 avgt 15 1021.422 ? 5.979 ns/op
-StringConcat.concat23String 4711 avgt 15 80.279 ? 0.338 ns/op
-StringConcat.concat23StringConst 4711 avgt 15 103.502 ? 0.477 ns/op
-StringConcat.concat30Mix 4711 avgt 15 339.447 ? 14.675 ns/op
+# current
+Benchmark (intValue) Mode Cnt Score Error Units
+StringConcat.concat123String 4711 avgt 15 1021.422 ? 5.979 ns/op
+StringConcat.concat23String 4711 avgt 15 80.279 ? 0.338 ns/op
+StringConcat.concat23StringConst 4711 avgt 15 103.502 ? 0.477 ns/op
+StringConcat.concat30Mix 4711 avgt 15 339.447 ? 14.675 ns/op
| | baseline | current | delta |
| --- | --- | --- | --- |
| StringConcat.concat123String | 1078.649 | 1021.422 | 5.60% |
| StringConcat.concat23String | 139.407 | 80.279 | 73.65% |
| StringConcat.concat23StringConst | 119.125 | 103.502 | 15.09% |
| StringConcat.concat30Mix | 425.278 | 339.447 | 25.29% |
-------------
PR Comment: https://git.openjdk.org/jdk/pull/20675#issuecomment-2308154069
More information about the core-libs-dev
mailing list