On Wed, 30 Apr 2025 15:59:05 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> This PR optimizes `BigInteger.pow(int)` method. The primary enhancement in >> `pow()` is not concerned most on execution time, but rather in memory >> optimization, because the PR implementation does the "shift of the exponent" >> squaring the result rather than the base, so the base is not squared like in >> the current implementation, and this permits to save about half of the >> memory. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision: > > Simplify long power computing test/micro/org/openjdk/bench/java/math/BigIntegerPow.java line 72: > 70: > 71: new Runner(opt).run(); > 72: } There's no need for these lines. test/micro/org/openjdk/bench/java/math/BigIntegerPow.java line 117: > 115: @OperationsPerInvocation(TESTSIZE) > 116: public void testPowXS(Blackhole bh) { > 117: for (BigInteger s : xsArray) { Suggestion: for (BigInteger xs : xsArray) { and similarly for the other arrays. test/micro/org/openjdk/bench/java/math/BigIntegerPow.java line 118: > 116: public void testPowXS(Blackhole bh) { > 117: for (BigInteger s : xsArray) { > 118: bh.consume(s.pow(xsExp)); Suggestion: bh.consume(s.pow(xsExp & ~0b0111_0101)); bh.consume(s.pow(xsExp)); bh.consume(s.pow(xsExp + 1)); or something similar, just to measure other than "all-ones" exponents as well. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2077443258 PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2077449324 PR Review Comment: https://git.openjdk.org/jdk/pull/24690#discussion_r2077452722