<i18n dev> RFR: 8275863: Use encodeASCII for ASCII-compatible DoubleByte encodings

Alan Bateman alanb at openjdk.java.net
Tue Oct 26 19:08:15 UTC 2021


On Mon, 25 Oct 2021 10:16:23 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> Enhance ASCII-compatible `DoubleByte` encodings to make use of the `StringCoding.implEncodeAsciiArray` intrinsic, which makes many such `CharsetEncoder`s encode ASCII text at speeds comparable to most single-byte encoders - and also more in line with how well these charsets behave when calling `String.getBytes`:
> 
> Before:
> 
> Benchmark                   (size)      (type)  Mode  Cnt   Score   Error  Units
> CharsetEncodeDecode.encode   16384  ISO-8859-1  avgt   30   3.021 ± 0.120  us/op
> CharsetEncodeDecode.encode   16384   Shift-JIS  avgt   30  47.793 ± 1.942  us/op
> CharsetEncodeDecode.encode   16384      GB2312  avgt   30  49.598 ± 2.006  us/op
> CharsetEncodeDecode.encode   16384      EUC-JP  avgt   30  68.709 ± 5.019  us/op
> CharsetEncodeDecode.encode   16384      EUC-KR  avgt   30  48.033 ± 1.651  us/op
> 
> 
> Patched:
> 
> Benchmark                   (size)      (type)  Mode  Cnt  Score   Error  Units
> CharsetEncodeDecode.encode   16384  ISO-8859-1  avgt   30  2.856 ± 0.078  us/op
> CharsetEncodeDecode.encode   16384   Shift-JIS  avgt   30  5.287 ± 0.209  us/op
> CharsetEncodeDecode.encode   16384      GB2312  avgt   30  5.490 ± 0.251  us/op
> CharsetEncodeDecode.encode   16384      EUC-JP  avgt   30  7.657 ± 0.368  us/op
> CharsetEncodeDecode.encode   16384      EUC-KR  avgt   30  5.718 ± 0.267  us/op
> 
> 
> The `isASCIICompatible` predicate on `DoubleByte` was added in JEP 254 for the purpose of implementing such ASCII fast-paths, but is only used in what is now `String.encodeWithEncoder` to speed up `String.getBytes(...)` operations.
> 
> Testing: tier1-3

Good work

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

Marked as reviewed by alanb (Reviewer).

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


More information about the i18n-dev mailing list