On Wed, 15 Dec 2021 23:04:37 GMT, Claes Redestad <[email protected]> wrote:
> 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
LGTM.
test/micro/org/openjdk/bench/java/lang/Integers.java line 66:
> 64: intsTiny = new int[size];
> 65: intsSmall = new int[size];
> 66: intsBig = new int[size];
Stray extra space.
-------------
Marked as reviewed by rriggs (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/6854