Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2025-05-05 Thread Andrey Turbanov
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread duke
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Roger Riggs
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Chen Liang
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Roger Riggs
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Chen Liang
On Fri, 19 Jul 2024 21:46:07 GMT, Roger Riggs wrote: >> Shaojin Wen has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Update src/java.base/share/classes/java/lang/String.java >> >>Co-authored-by: Chen Liang >> - add comments >

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Chen Liang
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Claes Redestad
On Tue, 23 Jul 2024 12:49:52 GMT, Shaojin Wen wrote: >> Yes, this isn't beholden to JLS 15.18.1, and it's already specified that >> `foo.concat("")` returns `foo` - so why shouldn't `"".concat(foo)` return >> `foo`? But still it's an observable semantic change so some care needs to be >> taken

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Claes Redestad
On Tue, 23 Jul 2024 12:56:07 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Shaojin Wen
On Tue, 23 Jul 2024 12:37:40 GMT, Claes Redestad wrote: >> The spec for concat only asked for equal representation instead of the >> existence of a new identity. Thus this should be fine. > > Yes, this isn't beholden to JLS 15.18.1, and it's already specified that > `foo.concat("")` returns `fo

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v7]

2024-07-23 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision: reduce change --

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Claes Redestad
On Tue, 23 Jul 2024 12:12:41 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/lang/String.java line 2991: >> >>> 2989: } >>> 2990: if (isEmpty()) { >>> 2991: return str; >> >> This case should probably be reflected more precisely in the specification, >> o

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v6]

2024-07-23 Thread Chen Liang
On Tue, 23 Jul 2024 12:16:00 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request with a new target base due to

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Chen Liang
On Tue, 23 Jul 2024 12:01:51 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Update src/java.base/share/classes/java/lang/String.java >> >>Co-authored-by: Chen Liang >> - add comments

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v6]

2024-07-23 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commi

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-23 Thread Claes Redestad
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-22 Thread Chen Liang
On Mon, 22 Jul 2024 07:24:08 GMT, Shaojin Wen wrote: >>> If code is generated through ClassFile, how to access the private methods >>> of classes such as String/StringConcatHelper? >> >> In that case, you have to encode those methods as live `MethodHandle` >> objects, passed to the generated c

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-22 Thread Shaojin Wen
On Sat, 20 Jul 2024 06:41:25 GMT, Chen Liang wrote: > > If code is generated through ClassFile, how to access the private methods > > of classes such as String/StringConcatHelper? > > In that case, you have to encode those methods as live `MethodHandle` > objects, passed to the generated class

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-20 Thread Chen Liang
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-20 Thread Chen Liang
On Sat, 20 Jul 2024 13:16:16 GMT, Brett Okken wrote: >> src/java.base/share/classes/java/lang/StringConcatHelper.java line 387: >> >>> 385: byte[] buf = newArray(newLength); >>> 386: s1.getBytes(buf, 0, coder); >>> 387: s2.getBytes(buf, s1.length(), coder); >> >> Does s1

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-20 Thread Brett Okken
On Sat, 20 Jul 2024 13:11:33 GMT, Brett Okken wrote: >> Shaojin Wen has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Update src/java.base/share/classes/java/lang/String.java >> >>Co-authored-by: Chen Liang >> - add comments >

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-20 Thread Brett Okken
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Chen Liang
On Sat, 20 Jul 2024 06:28:12 GMT, Shaojin Wen wrote: > If code is generated through ClassFile, how to access the private methods of > classes such as String/StringConcatHelper? In that case, you have to encode those methods as live `MethodHandle` objects, passed to the generated class with `de

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 22:49:41 GMT, Shaojin Wen wrote: >> FWIW one of the ideas when implementing `StringConcatHelper.simpleConcat` >> was that by using the primitives used by the `StringConcatFactory` as >> straightforwardly as possible the method acts as a documentation-of-sorts or >> guide to

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Claes Redestad
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 22:28:40 GMT, Claes Redestad wrote: >> Shaojin Wen has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Update src/java.base/share/classes/java/lang/String.java >> >>Co-authored-by: Chen Liang >> - add comments

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Claes Redestad
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Roger Riggs
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 21:42:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with two additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v3]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 21:33:09 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v5]

2024-07-19 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request incrementally with two additional commits since the last revision: - Update src/java.bas

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v4]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 21:34:36 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v4]

2024-07-19 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision: handle null argument

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v3]

2024-07-19 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision: extract a common doCo

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 19:18:43 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 20:43:42 GMT, Chen Liang wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> share newArray > > As annoying and risky as this first appeared, this patch is actually in quite > good shape: The usage

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 20:18:04 GMT, Chen Liang wrote: >> Shaojin Wen has updated the pull request incrementally with one additional >> commit since the last revision: >> >> share newArray > > src/java.base/share/classes/java/lang/StringConcatHelper.java line 371: > >> 369: return n

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 20:55:03 GMT, Shaojin Wen wrote: >> src/java.base/share/classes/java/lang/StringConcatHelper.java line 371: >> >>> 369: return new String(s1); >>> 370: } >>> 371: byte coder = (byte) (s1.coder() | s2.coder()); >> >> Suggestion: >> >> int

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 19:18:43 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 19:18:43 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 17:35:45 GMT, Chen Liang wrote: > Also beware of #19927: it simplifies the prepend part. How does that patch > run in your benchmark? The performance comparison I made is based on the latest master branch ([c25c4896ad9ef031e3cddec493aef66ff87c48a7](https://github.com/openjd

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 19:18:43 GMT, Shaojin Wen wrote: >> Currently simpleConcat is implemented using mix and prepend, but in this >> simple scenario, it can be implemented in a simpler way and can improve >> performance. > > Shaojin Wen has updated the pull request incrementally with one additio

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat [v2]

2024-07-19 Thread Shaojin Wen
> Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision: share newArray -

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 13:10:43 GMT, Shaojin Wen wrote: > Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Changes requested by liach (Reviewer). src/java.base/share/classes/java/lang

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat

2024-07-19 Thread Chen Liang
On Fri, 19 Jul 2024 13:10:43 GMT, Shaojin Wen wrote: > Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Also beware of #19927: it simplifies the prepend part. How does that patch ru

Re: RFR: 8336831: Optimize StringConcatHelper.simpleConcat

2024-07-19 Thread Shaojin Wen
On Fri, 19 Jul 2024 13:10:43 GMT, Shaojin Wen wrote: > Currently simpleConcat is implemented using mix and prepend, but in this > simple scenario, it can be implemented in a simpler way and can improve > performance. Below are the performance numbers running on a MacBook M1 Pro, which is 8.71%