On Sun, 13 Oct 2024 14:39:32 GMT, j3graham <d...@openjdk.org> wrote: >> fabioromano1 has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Minor change > > src/java.base/share/classes/java/math/BigDecimal.java line 5234: > >> 5232: */ >> 5233: private static BigInteger fiveToTwoToThe(int n) { >> 5234: int i = Math.min(n, FIVE_TO_2_TO.length - 1); > > BigInteger has “getRadixConversionCache” which could be made accessible and > used here - perhaps with a better name.
@j3graham The benchmarks using `getRadixConversionCache()` look good (see below). The problem with this is that the cache maintained by that method is unlimited, whereas the one controlled by `fiveToTwoToThe()` has modest memory requirements. Benchmark Mode Cnt Score Error Units BigDecimalStripTrailingZeros.testL avgt 15 2723753.867 ? 9200.262 ns/op BigDecimalStripTrailingZeros.testM avgt 15 9269.359 ? 32.427 ns/op BigDecimalStripTrailingZeros.testS avgt 15 155.660 ? 0.807 ns/op BigDecimalStripTrailingZeros.testXL avgt 15 445079302.800 ? 969170.405 ns/op BigDecimalStripTrailingZeros.testXS avgt 15 21.305 ? 0.029 ns/op Finished running test 'micro:java.math.BigDecimalStripTrailingZeros' @j3graham The benchmarks using `getRadixConversionCache()` look good (see below). The problem with this is that the cache maintained by that method is unlimited, whereas the one controlled by `fiveToTwoToThe()` has modest memory requirements. Benchmark Mode Cnt Score Error Units BigDecimalStripTrailingZeros.testL avgt 15 2723753.867 ? 9200.262 ns/op BigDecimalStripTrailingZeros.testM avgt 15 9269.359 ? 32.427 ns/op BigDecimalStripTrailingZeros.testS avgt 15 155.660 ? 0.807 ns/op BigDecimalStripTrailingZeros.testXL avgt 15 445079302.800 ? 969170.405 ns/op BigDecimalStripTrailingZeros.testXS avgt 15 21.305 ? 0.029 ns/op Finished running test 'micro:java.math.BigDecimalStripTrailingZeros' ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798409738 PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798410039