RFR: 8284637: Improve String.join performance

XenoAmess duke at openjdk.java.net
Mon Apr 11 20:18:33 UTC 2022


On Mon, 11 Apr 2022 19:22:21 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Is there jmh test data to quantify the improvement?

Not yet as I don't really know how to run a jmh for a package static function, who calls some other class private functions...

Should I put the test upon StringJoiner insterad, as it called String.join? 

I would have a try.

> src/java.base/share/classes/java/lang/String.java line 3290:
> 
>> 3288:                         value,
>> 3289:                         off << coder,
>> 3290:                         delimiterLengthWithCoder
> 
> Is there any benefit to special casing short delimiters?  1..4 bytes?
> Arraycopy has a fixed overhead regardless of the delimiter length.
> I might expect a big payoff for coder = Latin1 and delimiter length == 1..2  compared to arraycopy.

yes I think there should be performance benifitial when delimiter coder be Latin 1 and output not, which would call StringLatin1.inflate for many times, that is a waste.

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

PR: https://git.openjdk.java.net/jdk/pull/8169


More information about the core-libs-dev mailing list