On Thu, 7 Jul 2022 15:20:32 GMT, Raffaello Giulietti <d...@openjdk.org> wrote:
> A reimplementation of `BigDecimal.[double|float]Value()` to enhance > performance, avoiding an intermediate string and its subsequent parsing on > the slow path. These are the improvements over the current implementation: - Much more cases are processed by the fast path. - Most values that will either produce 0 or infinity are detected early in a fast way to avoid expensive computations. - If neither of the above applies, the conversion to `String` and subsequent parsing, as currently done, is replaced by `BigInteger` arithmetic. There's at most one division between `BigInteger`s. Of course, no need for `toString()` nor parsing. - Extensive comments explain all the details. JMH benchmarks show that, on the fast path, the new implementation is on par or way better (>200x for the cases not currently covered). Cases where 0 or infinity are detected early contribute with speedup factors of >200x. `BigInteger` arithmetic contributes with speed factors of 2x-8x on "typical" `BigDecimal`s of precision 18 to 24 and scale 2 to 6. ------------- PR: https://git.openjdk.org/jdk/pull/9410