RFR: 8302204: Optimize BigDecimal.divide

Xiaowei Lu duke at openjdk.org
Wed Mar 1 06:43:05 UTC 2023


On Fri, 17 Feb 2023 15:24:26 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>>> After making sure that `intVal` is even, and before attempting a division by a power of 10, it might help to check if 5 divides `intVal` in the first place. If it doesn't, there no point in performing the division.
>>> 
>>> It can be shown that 5 divides `intVal` if and only if it divides the `long` sum of all `int`s in the `mag` array of `intVal`.
>>> 
>>> I didn't try out if this contributes to improve the overall performance, but it might be worth giving a try.
>> 
>> Unfortunately, it seems this division by 5 doesn't give an obvious performance improvement. Maybe previous lowest bit check has filtered some cases.
>
>> > After making sure that `intVal` is even, and before attempting a division by a power of 10, it might help to check if 5 divides `intVal` in the first place. If it doesn't, there no point in performing the division.
>> > It can be shown that 5 divides `intVal` if and only if it divides the `long` sum of all `int`s in the `mag` array of `intVal`.
>> > I didn't try out if this contributes to improve the overall performance, but it might be worth giving a try.
>> 
>> Unfortunately, it seems this division by 5 doesn't give an obvious performance improvement. Maybe previous lowest bit check has filtered some cases.
> 
> Thanks for trying out.

@rgiulietti Hi, could you please review this pr

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

PR: https://git.openjdk.org/jdk/pull/12509


More information about the core-libs-dev mailing list