math/big: pool temporary variables to reduce allocations of Int.ModInverse#79708
math/big: pool temporary variables to reduce allocations of Int.ModInverse#79708allocz wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
This PR (HEAD: c5ff0e5) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/783861. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Jorropo: Patch Set 1: Hold+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Jorropo: Patch Set 1: Commit-Queue+1 (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-05-28T00:11:31Z","revision":"a78b16c8a8123613aed58459926b4d895ea21f96"} Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Jorropo: Patch Set 1: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_55763>) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
This PR (HEAD: ae66eba) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/783861. Important tips:
|
|
Message from Mateusz Poliwczak: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Alan Donovan: Patch Set 3: Hold+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Alan Donovan: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Mateusz Poliwczak: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from allocz: Patch Set 3: Code-Review+1 (5 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Mateusz Poliwczak: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from Alan Donovan: Patch Set 4: Hold+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
This PR (HEAD: a0031fa) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/783861. Important tips:
|
|
Message from Jorropo: Patch Set 5: Hold+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from allocz: Patch Set 4: Code-Review+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
|
Message from allocz: Patch Set 6: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/783861. |
Before the changes, Int.ModInverse was doing several allocations for
temporary variables, this PR added pooling for those, effectively
reducing the total amount of allocations as the benchmarks below show.
goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Core(TM) i5-1031`0U CPU @ 1.70GHz
│ /tmp/before │ /tmp/after │
│ sec/op │ sec/op vs base │
ModInverse-8 815.9n ± 7% 450.6n ± 6% -44.78% (p=0.000 n=10)
ModInverse-8 1.055Ki ± 0% 0.000Ki ± 0% -100.00% (p=0.000 n=10)
ModInverse-8 11.00 ± 0% 0.00 ± 0% -100.00% (p=0.000 n=10)
As we can see, ModInverse is faster now.
This merge request Closes #79707