<i18n dev> RFR: 8304245: Speed up CharacterData.of by avoiding bit shifting in the latin1 fast-path test

Eirik Bjorsnos duke at openjdk.org
Wed Mar 15 12:19:21 UTC 2023


On Wed, 15 Mar 2023 12:13:00 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> Btw, I think we can do the same for `StringLatin1.canEncode()`
>
> It seems reasonable to keep these two in sync, yes. (`CharacterData.of` could even call into `StringLatin1.canEncode`, unless that's cause for some performance anomaly)

> `if (ch && 0xFFFFFF00 == 0) {`

This seems to perform similar to baseline:


Benchmark           (codePoint)  Mode  Cnt  Score   Error  Units
Characters.isDigit           48  avgt   15  0.890 ± 0.025  ns/op
Characters.isDigit         1632  avgt   15  2.174 ± 0.011  ns/op


Would be interesting to check the performance on non-Intel architectures. If you want to give it a spin on your M1, here's the benchmark command I used:

`make test TEST='micro:java.lang.Characters.isDigit' MICRO="OPTIONS=-p codePoint=48,1632"`

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

PR: https://git.openjdk.org/jdk/pull/13040


More information about the i18n-dev mailing list