RFR: 8278831: Use table lookup for the last two bytes in Integer.getChars
Claes Redestad
redestad at openjdk.java.net
Thu Dec 16 10:17:21 UTC 2021
During TemplatedStrings work Jim has noticed that we could probably profit from reusing the lookup tables also for the 1 or 2 leftmost bytes:
// We know there are at most two digits left at this point.
buf[--charPos] = DigitOnes[-i];
if (i < -9) {
buf[--charPos] = DigitTens[-i];
}
This avoids some arithmetic, and on average achieves a small speed-up since the lookup tables are likely cached are likely to be in cache. Small improvements on a few affected microbenchmarks, including the new Integers.toStringTiny, can be observed.
Baseline:
Benchmark (size) Mode Cnt Score Error Units
Integers.toStringTiny 500 avgt 50 21.862 ± 0.211 us/op
Patch:
Benchmark (size) Mode Cnt Score Error Units
Integers.toStringTiny 500 avgt 50 20.619 ± 0.330 us/op
-------------
Commit messages:
- 8278831: Use table lookup for the last two bytes in Integer.getChars
Changes: https://git.openjdk.java.net/jdk/pull/6854/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6854&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8278831
Stats: 42 lines in 4 files changed: 11 ins; 16 del; 15 mod
Patch: https://git.openjdk.java.net/jdk/pull/6854.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6854/head:pull/6854
PR: https://git.openjdk.java.net/jdk/pull/6854
More information about the core-libs-dev
mailing list