RFR: 8367324: Avoid redundant parsing when formatting with DigitList [v2]

Johannes Graham duke at openjdk.org
Thu Sep 11 14:42:07 UTC 2025


On Wed, 10 Sep 2025 23:47:47 GMT, Johannes Graham <duke at openjdk.org> wrote:

>> When formatting doubles or BigDecimals, DigitList first formats them as a string and then parses the resultant string to extract the mantissa and the exponent. This can be done more directly. This allows removing some parsing code and removes a cached byte array.
>> 
>> This also facilitates potential cleanups in FloatingDecimal (removal of getChars method) but I've left that for later to minimize conflicts with other changes there.
>
> Johannes Graham has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - use Level.Invocation
>  - review fixes

Updated Benchmark numbers using `@Setup(Level.Invocation)`


Baseline 


Benchmark                                              Mode  Cnt      Score     Error   Units
DefFormatterBench.testDefNumberFormatter             thrpt   15  14493.498 ± 240.094  ops/ms
DefFormatterBench.testLargeBigDecDefNumberFormatter  thrpt   15   3680.037 ±  90.755  ops/ms
DefFormatterBench.testSmallBigDecDefNumberFormatter  thrpt   15  18270.715 ± 666.360  ops/ms



This PR without BigInteger fast-path


Benchmark                                              Mode  Cnt      Score     Error   Units
DefFormatterBench.testDefNumberFormatter             thrpt   15  18463.554 ± 540.881  ops/ms  +27%
DefFormatterBench.testLargeBigDecDefNumberFormatter  thrpt   15   4416.749 ±  81.965  ops/ms  +20%
DefFormatterBench.testSmallBigDecDefNumberFormatter  thrpt   15  14829.697 ± 235.140  ops/ms  -18%



This PR with fast-path


Benchmark                                              Mode  Cnt      Score     Error   Units
DefFormatterBench.testDefNumberFormatter             thrpt   15  18926.301 ± 346.970  ops/ms  +30%
DefFormatterBench.testLargeBigDecDefNumberFormatter  thrpt   15   4511.169 ±  65.314  ops/ms  +23%
DefFormatterBench.testSmallBigDecDefNumberFormatter  thrpt   15  25409.301 ± 630.107  ops/ms  +39%

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

PR Comment: https://git.openjdk.org/jdk/pull/27118#issuecomment-3281137706


More information about the core-libs-dev mailing list