Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v3]

2024-02-20 Thread Claes Redestad
On Tue, 20 Feb 2024 18:42:16 GMT, Claes Redestad wrote: >> JDK-8282429 accidentally removed an optimization (JDK-8240094) that ensured >> StringBuilder/StringBuffer::toString returns `""` when the builders are >> empty. >> >> >> Name Cnt Base Error Test Er

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v3]

2024-02-20 Thread Aleksey Shipilev
On Tue, 20 Feb 2024 18:38:48 GMT, Claes Redestad wrote: >> JDK-8282429 accidentally removed an optimization (JDK-8240094) that ensured >> StringBuilder/StringBuffer::toString returns `""` when the builders are >> empty. >> >> >> Name Cnt Base Error Test Er

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v3]

2024-02-20 Thread Claes Redestad
> 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.emptyToString5 12,289 ±

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v3]

2024-02-20 Thread Claes Redestad
On Tue, 20 Feb 2024 18:30:25 GMT, Aleksey Shipilev wrote: >> It's needed again now that I reverted the code removals.. :-) > > Mhm. I don't see any new `@Setup` methods anywhere. Just checked out the PR > locally, removed this import and benchmarks still build, and > `StringBuilderToString` ben

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]

2024-02-20 Thread Aleksey Shipilev
On Tue, 20 Feb 2024 18:04:18 GMT, Claes Redestad wrote: >> src/java.base/share/classes/java/lang/StringBuilder.java line 478: >> >>> 476: } >>> 477: // Create a copy, don't share the array >>> 478: return new String(this, null); >> >> Ok, this got me a bit confused, but

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]

2024-02-20 Thread Claes Redestad
On Tue, 20 Feb 2024 18:08:11 GMT, Aleksey Shipilev wrote: >> I couldn't figure out why we'd want to have `String::substring` micros in a >> test `StringBuffers` (there's also a `StringSubstring` micro), though I >> could deal with that as an explicit cleanup RFE. > > Yeah, I would like to keep

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]

2024-02-20 Thread Aleksey Shipilev
On Tue, 20 Feb 2024 18:00:42 GMT, Claes Redestad wrote: >> test/micro/org/openjdk/bench/java/lang/StringBuffers.java line 49: >> >>> 47: >>> 48: @Benchmark >>> 49: public String emptyToString() { >> >> Do we actually need to remove the `substring` test here? > > I couldn't figure out w

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]

2024-02-20 Thread Claes Redestad
On Tue, 20 Feb 2024 17:02:40 GMT, Aleksey Shipilev wrote: >> 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 > > src/java.base/share/classes/ja

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String [v2]

2024-02-20 Thread Claes Redestad
> 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.emptyToString5 12,289 ±

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String

2024-02-20 Thread Claes Redestad
On Tue, 20 Feb 2024 17:00:14 GMT, Aleksey Shipilev wrote: >> JDK-8282429 accidentally removed an optimization (JDK-8240094) that ensured >> StringBuilder/StringBuffer::toString returns `""` when the builders are >> empty. >> >> >> Name Cnt Base Error Test

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String

2024-02-20 Thread Aleksey Shipilev
On Tue, 20 Feb 2024 16:32:54 GMT, Claes Redestad wrote: > 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 Uni

Re: RFR: 8325730: StringBuilder.toString allocation for the empty String

2024-02-20 Thread Jim Laskey
On Tue, 20 Feb 2024 16:32:54 GMT, Claes Redestad wrote: > 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 Uni

RFR: 8325730: StringBuilder.toString allocation for the empty String

2024-02-20 Thread Claes Redestad
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.emptyToString5 12,289 ±0,384 9,8