RFR: 8336274: MutableBigInteger.leftShift(int) optimization [v5]

Raffaello Giulietti rgiulietti at openjdk.org
Tue Sep 3 17:00:21 UTC 2024


On Mon, 2 Sep 2024 16:19:01 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> This implementation of MutableBigInteger.leftShift(int) optimizes the current version, avoiding unnecessary copy of the MutableBigInteger's value content and performing the primitive shifting only in the original portion of the value array rather than in the value yet extended with trailing zeros.
>
> fabioromano1 has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Merge branch 'openjdk:master' into patchLeftShift
>  - Code more clear
>  - Tests changes
>  - Merge branch 'openjdk:master' into patchLeftShift
>  - Removed trailing whitespace
>  - MutableBigInteger.leftShift(int) optimization

I ran the benchmark `BigIntegerSquareRoot`.

Compared to the results in the [current code](https://github.com/openjdk/jdk/pull/19710#issuecomment-2261214678), there are no significant improvements with the code in this PR.


Benchmark                        Mode  Cnt      Score     Error  Units
BigIntegerSquareRoot.testSqrtL   avgt   15   2717.091 ?  25.832  ns/op
BigIntegerSquareRoot.testSqrtM   avgt   15    741.335 ?  14.198  ns/op
BigIntegerSquareRoot.testSqrtS   avgt   15    202.612 ?   4.015  ns/op
BigIntegerSquareRoot.testSqrtXL  avgt   15  21090.732 ? 367.495  ns/op
BigIntegerSquareRoot.testSqrtXS  avgt   15      4.776 ?   0.104  ns/op

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

PR Comment: https://git.openjdk.org/jdk/pull/20008#issuecomment-2327011588


More information about the core-libs-dev mailing list