RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]
Claes Redestad
redestad at openjdk.org
Tue Feb 20 18:15:05 UTC 2024
> JDK-8282429 accidentally removed an optimization (JDK-8240094) that ensured StringBuilder/StringBuffer::toString returns `""` when the builders are empty.
>
>
> Name Cnt Base Error Test Error Unit Change
> StringBuffers.emptyToString 5 12,289 ± 0,384 9,883 ± 0,721 ns/op 1,24x (p = 0,000*)
> :gc.alloc.rate 1862,398 ± 57,647 0,007 ± 0,000 MB/sec 0,00x (p = 0,000*)
> :gc.alloc.rate.norm 24,000 ± 0,000 0,000 ± 0,000 B/op 0,00x (p = 0,000*)
> :gc.count 31,000 0,000 counts
> :gc.time 21,000 ms
> StringBuilders.emptyToString 5 4,146 ± 0,567 0,646 ± 0,003 ns/op 6,42x (p = 0,000*)
> :gc.alloc.rate 9208,656 ± 1234,399 0,007 ± 0,000 MB/sec 0,00x (p = 0,000*)
> :gc.alloc.rate.norm 40,000 ± 0,000 0,000 ± 0,000 B/op 0,00x (p = 0,000*)
> :gc.count 96,000 0,000 counts
> :gc.time 64,000 ms
> * = significant
Claes Redestad has updated the pull request incrementally with two additional commits since the last revision:
- Revert StringBuffers removals
- Update from review comments by @shipilev
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/17931/files
- new: https://git.openjdk.org/jdk/pull/17931/files/7f9566b8..40cca3e3
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=17931&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=17931&range=00-01
Stats: 41 lines in 2 files changed: 38 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/17931.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17931/head:pull/17931
PR: https://git.openjdk.org/jdk/pull/17931
More information about the core-libs-dev
mailing list