RFR: 8355719: Reduce memory consumption of BigInteger.pow() [v38]
Chen Liang
liach at openjdk.org
Mon Apr 28 14:14:53 UTC 2025
On Mon, 28 Apr 2025 07:29:10 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/math/BigInteger.java line 2746:
>>
>>> 2744: if (exp <= maxExp) {
>>> 2745: // don't use fp arithmetic if exp <= 3
>>> 2746: xToExp = exp == 1 ? x :
>>
>> What about pre-seeding the cache with values for 1, 2 and 3? That would allow unconditionally using fp here (and below)
>
>> What about pre-seeding the cache with values for 1, 2 and 3? That would allow unconditionally using fp here (and below)
>
> It's a good idea, but doing so would increase the already high dependence of `computePower()` by the preconditions given by `unsignedLongPow()`, so at this point I wonder if it will still make sense to maintain the code separated, rather than putting it in `unsignedLongPow()` and throw away `computePower()`...
Doesn't pre-seeding involve extra cpu cycles which are defintely wasted if the results aren't used?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2063752957
More information about the core-libs-dev
mailing list