[go] math/big: Int.ModInverse: pool temporary allocations to reduce allocations

6 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
May 27, 2026, 7:51:50 PMMay 27
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

math/big: Int.ModInverse: pool temporary allocations to reduce allocations

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.

Before:
```
$ go test ./math/big -v -count=1 -p=1 -run=NONE -bench=BenchmarkModInverse -benchmem -benchtime=100000x
goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
BenchmarkModInverse
BenchmarkModInverse-8 100000 907.2 ns/op 1080 B/op 11 allocs/op
PASS
ok math/big 0.110s
```

After:
```
$ go test ./math/big -v -count=1 -p=1 -run=NONE -bench=BenchmarkModInverse -benchmem -benchtime=100000x
goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
BenchmarkModInverse
BenchmarkModInverse-8 100000 537.7 ns/op 0 B/op 0 allocs/op
PASS
ok math/big 0.072s
```

As we can see, ModInverse is faster now.

This merge request Closes #79707
Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
GitHub-Last-Rev: c5ff0e509a185058d3c45c738e42861432c3ccb9
GitHub-Pull-Request: golang/go#79708

Change diff

diff --git a/src/math/big/int.go b/src/math/big/int.go
index f2331b5..91ed8d8 100644
--- a/src/math/big/int.go
+++ b/src/math/big/int.go
@@ -11,6 +11,7 @@
"io"
"math/rand"
"strings"
+ "sync"
)

// An Int represents a signed multi-precision integer.
@@ -829,6 +830,35 @@
return B, r, A, Ua, Ub
}

+type sixIntPool struct {
+ pool sync.Pool
+}
+
+func (t *sixIntPool) Put(data *[6]*Int) {
+ data[0].SetInt64(0)
+ data[1].SetInt64(0)
+ data[2].SetInt64(0)
+ data[3].SetInt64(0)
+ data[4].SetInt64(0)
+ data[5].SetInt64(0)
+ t.pool.Put(data)
+}
+
+func (t *sixIntPool) Get() *[6]*Int {
+ return t.pool.Get().(*[6]*Int)
+}
+
+var sixIntP = sixIntPool{
+ sync.Pool{
+ New: func() any {
+ data := [6]*Int{
+ &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{},
+ }
+ return &data
+ },
+ },
+}
+
// lehmerGCD sets z to the greatest common divisor of a and b,
// which both must be != 0, and returns z.
// If x or y are not nil, their values are set such that z = a*x + b*y.
@@ -840,22 +870,22 @@
// The cosequences are updated according to Algorithm 10.45 from
// Cohen et al. "Handbook of Elliptic and Hyperelliptic Curve Cryptography" pp 192.
func (z *Int) lehmerGCD(x, y, a, b *Int) *Int {
- var A, B, Ua, Ub *Int
+ data := sixIntP.Get()
+ var A, B, Ua, Ub *Int = data[0], data[1], data[2], data[3]

- A = new(Int).Abs(a)
- B = new(Int).Abs(b)
+ A.Abs(a)
+ B.Abs(b)

extended := x != nil || y != nil

if extended {
// Ua (Ub) tracks how many times input a has been accumulated into A (B).
- Ua = new(Int).SetInt64(1)
- Ub = new(Int)
+ Ua.SetInt64(1)
}

// temp variables for multiprecision update
- q := new(Int)
- r := new(Int)
+ q := data[4]
+ r := data[5]

// ensure A >= B
if A.abs.cmp(B.abs) < 0 {
@@ -947,6 +977,8 @@

z.Set(A)

+ sixIntP.Put(data)
+
return z
}

@@ -966,6 +998,29 @@
return z
}

+type twoIntPool struct {
+ pool sync.Pool
+}
+
+func (t *twoIntPool) Put(data *[2]*Int) {
+ data[0].SetInt64(0)
+ data[1].SetInt64(0)
+ t.pool.Put(data)
+}
+
+func (t *twoIntPool) Get() *[2]*Int {
+ return t.pool.Get().(*[2]*Int)
+}
+
+var twoIntP = twoIntPool{
+ sync.Pool{
+ New: func() any {
+ data := [2]*Int{&Int{}, &Int{}}
+ return &data
+ },
+ },
+}
+
// ModInverse sets z to the multiplicative inverse of g in the ring ℤ/nℤ
// and returns z. If g and n are not relatively prime, g has no multiplicative
// inverse in the ring ℤ/nℤ. In this case, z is unchanged and the return value
@@ -980,8 +1035,10 @@
var g2 Int
g = g2.Mod(g, n)
}
- var d, x Int
- d.GCD(&x, nil, g, n)
+
+ data := twoIntP.Get()
+ var d, x *Int = data[0], data[1]
+ d.GCD(x, nil, g, n)

// if and only if d==1, g and n are relatively prime
if d.Cmp(intOne) != 0 {
@@ -991,10 +1048,13 @@
// x and y are such that g*x + n*y = 1, therefore x is the inverse element,
// but it may be negative, so convert to the range 0 <= z < |n|
if x.neg {
- z.Add(&x, n)
+ z.Add(x, n)
} else {
- z.Set(&x)
+ z.Set(x)
}
+
+ twoIntP.Put(data)
+
return z
}

Change information

Files:
  • M src/math/big/int.go
Change size: M
Delta: 1 file changed, 71 insertions(+), 11 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
Gerrit-Change-Number: 783861
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
May 27, 2026, 7:51:53 PMMay 27
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. The first word in the commit title after the package should be a lowercase English word (usually a verb).
2. You have a long 205 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
3. It looks like you are using markdown in the commit message. If so, please remove it. Be sure to double-check the plain text shown in the Gerrit commit message above for any markdown backticks, markdown links, or other markdown formatting.
4. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
    Gerrit-Change-Number: 783861
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Wed, 27 May 2026 23:51:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    May 27, 2026, 7:55:21 PMMay 27
    to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Message from Gopher Robot

    Congratulations on opening your first change. Thank you for your contribution!

    Next steps:
    A maintainer will review your change and provide feedback. See
    https://go.dev/doc/contribute#review for more info and tips to get your
    patch through code review.

    Most changes in the Go project go through a few rounds of revision. This can be
    surprising to people new to the project. The careful, iterative review process
    is our way of helping mentor contributors and ensuring that their contributions
    have a lasting impact.

    During May-July and Nov-Jan the Go project is in a code freeze, during which
    little code gets reviewed or merged. If a reviewer responds with a comment like
    R=go1.11 or adds a tag like "wait-release", it means that this CL will be
    reviewed as part of the next development cycle. See https://go.dev/s/release
    for more details.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
    Gerrit-Change-Number: 783861
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Wed, 27 May 2026 23:55:17 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Jorropo (Gerrit)

    unread,
    May 27, 2026, 7:57:37 PMMay 27
    to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    Jorropo voted Hold+1

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Holds
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
      Gerrit-Change-Number: 783861
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-Comment-Date: Wed, 27 May 2026 23:57:31 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy

      Jorropo (Gerrit)

      unread,
      May 27, 2026, 8:11:38 PMMay 27
      to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Robert Griesemer

      Jorropo voted and added 4 comments

      Votes added by Jorropo

      Commit-Queue+1

      4 comments

      Patchset-level comments
      Jorropo . resolved

      Thanks

      Commit Message
      Line 13, Patchset 1 (Latest):$ go test ./math/big -v -count=1 -p=1 -run=NONE -bench=BenchmarkModInverse -benchmem -benchtime=100000x
      Jorropo . unresolved

      Checkout https://pkg.go.dev/golang.org/x/perf/cmd/benchstat to make a table of statistical analysis results of your benchmarks.

      File src/math/big/int.go
      Line 980, Patchset 1 (Latest): sixIntP.Put(data)
      Jorropo . unresolved

      Any reason to not `defer` it when you `.Get` it ?

      Line 1056, Patchset 1 (Latest): twoIntP.Put(data)
      Jorropo . unresolved

      Any reason to not `defer` it when you `.Get` it ?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Robert Griesemer
      Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 1
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Comment-Date: Thu, 28 May 2026 00:11:31 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        May 28, 2026, 9:29:11 AMMay 28
        to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #2 to this change.
        Following approvals got outdated and were removed:
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jorropo
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        May 28, 2026, 10:08:24 AMMay 28
        to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #3 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jorropo
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 3
        unsatisfied_requirement
        open
        diffy

        Mateusz Poliwczak (Gerrit)

        unread,
        May 28, 2026, 10:48:02 AMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Mateusz Poliwczak added 1 comment

        File src/math/big/int.go
        Line 837, Patchset 3 (Latest):func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . unresolved

        Potentially

        ```suggestion
        func (t *sixIntPool) Put(data *[6]Int) {
        ```
        Could be better, less indirection.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jorropo
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Comment-Date: Thu, 28 May 2026 14:47:54 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        Alan Donovan (Gerrit)

        unread,
        May 28, 2026, 10:59:31 AMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Alan Donovan voted and added 2 comments

        Votes added by Alan Donovan

        Hold+1

        2 comments

        Patchset-level comments
        File-level comment, Patchset 3 (Latest):
        Alan Donovan . resolved

        Hold: since this is not a bug fix, it must wait till the tree thaws.

        File src/math/big/int.go
        Line 837, Patchset 3 (Latest):func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . unresolved

        Potentially

        ```suggestion
        func (t *sixIntPool) Put(data *[6]Int) {
        ```
        Could be better, less indirection.

        Alan Donovan

        Once you do that, you can universally generalize the two and six variants over `[T any]`: the pool stores a *T, the New operation calls new(T), and the Put operation just does `*ptr = *new(T)` to zeros out whatever value is stored.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jorropo
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Comment-Date: Thu, 28 May 2026 14:59:27 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Alan Donovan (Gerrit)

        unread,
        May 28, 2026, 11:01:59 AMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Alan Donovan added 1 comment

        File src/math/big/int.go
        Line 837, Patchset 3 (Latest):func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . unresolved

        Potentially

        ```suggestion
        func (t *sixIntPool) Put(data *[6]Int) {
        ```
        Could be better, less indirection.

        Alan Donovan

        Once you do that, you can universally generalize the two and six variants over `[T any]`: the pool stores a *T, the New operation calls new(T), and the Put operation just does `*ptr = *new(T)` to zeros out whatever value is stored.

        Alan Donovan

        (This assumes the goal of the CL is to amortize the allocation of the Ints themselves. If it is to recycle multi-word limb arrays, zeroing out won't do that. But I suspect the Ints are more important since most values are small and fit in a single limb.)

        Gerrit-Comment-Date: Thu, 28 May 2026 15:01:50 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
        Comment-In-Reply-To: Alan Donovan <adon...@google.com>
        unsatisfied_requirement
        open
        diffy

        Mateusz Poliwczak (Gerrit)

        unread,
        May 28, 2026, 11:02:37 AMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Jorropo and Robert Griesemer

        Mateusz Poliwczak added 1 comment

        File src/math/big/int.go
        Line 837, Patchset 3 (Latest):func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . unresolved

        Potentially

        ```suggestion
        func (t *sixIntPool) Put(data *[6]Int) {
        ```
        Could be better, less indirection.

        Alan Donovan

        Once you do that, you can universally generalize the two and six variants over `[T any]`: the pool stores a *T, the New operation calls new(T), and the Put operation just does `*ptr = *new(T)` to zeros out whatever value is stored.

        Mateusz Poliwczak

        and the Put operation just does *ptr = *new(T) to zeros out whatever value is stored.

        But you might want to re-use the `[]word` slices, `SetInt64` does that.

        Gerrit-Comment-Date: Thu, 28 May 2026 15:02:26 +0000
        unsatisfied_requirement
        open
        diffy

        allocz (Gerrit)

        unread,
        May 28, 2026, 1:26:22 PMMay 28
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Mateusz Poliwczak and Robert Griesemer

        allocz voted and added 5 comments

        Votes added by allocz

        Code-Review+1

        5 comments

        Patchset-level comments
        allocz . resolved

        The code fixes the main issue that is allocations in hot loops. Looks good to me.

        Commit Message
        Line 13, Patchset 1:$ go test ./math/big -v -count=1 -p=1 -run=NONE -bench=BenchmarkModInverse -benchmem -benchtime=100000x
        Jorropo . resolved

        Checkout https://pkg.go.dev/golang.org/x/perf/cmd/benchstat to make a table of statistical analysis results of your benchmarks.

        allocz

        Ok, I've updated the github PR message with the latest output of benchstat. Thanks.

        File src/math/big/int.go
        Line 837, Patchset 3 (Latest):func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . resolved

        Potentially

        ```suggestion
        func (t *sixIntPool) Put(data *[6]Int) {
        ```
        Could be better, less indirection.

        Alan Donovan

        Once you do that, you can universally generalize the two and six variants over `[T any]`: the pool stores a *T, the New operation calls new(T), and the Put operation just does `*ptr = *new(T)` to zeros out whatever value is stored.

        Mateusz Poliwczak

        and the Put operation just does *ptr = *new(T) to zeros out whatever value is stored.

        But you might want to re-use the `[]word` slices, `SetInt64` does that.

        allocz

        Firstly, thanks for the review, guys.

        I ran the benchmarks with less indirection `*[6]Int` instead of `*[6]*Int` and the results became slightly worse.

        In this case, the main goal is to avoid allocations of the internal Int `[]word`, in the ECDSA library that I'm optimizing, the Ints are in the order of 256 bits, so the generic version of the `twoIntPool` and `sixIntPool` causes allocations and because of that I will keep both pool implementations.

        I think that this is already good enough. Thanks again for the review.

        ```

        goos: linux
        goarch: amd64
        pkg: math/big
        cpu: Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
                     │ /tmp/arrayofpointerofint │           /tmp/arrayofint           │
        │ sec/op │ sec/op vs base │
        ModInverse-8 543.0n ± 0% 548.1n ± 8% +0.95% (p=0.004 n=100)
                     │ /tmp/arrayofpointerofint │         /tmp/arrayofint         │
        │ B/op │ B/op vs base │
        ModInverse-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=100) ¹
        ¹ all samples are equal
                     │ /tmp/arrayofpointerofint │         /tmp/arrayofint         │
        │ allocs/op │ allocs/op vs base │
        ModInverse-8 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=100) ¹
        ¹ all samples are equal
        ```
        Line 980, Patchset 1: sixIntP.Put(data)
        Jorropo . resolved

        Any reason to not `defer` it when you `.Get` it ?

        allocz

        Solved, I usually tend to avoid defer where performance matters because sometimes it prevents inlining or causes allocations, but this is not the case, thanks.

        Line 1056, Patchset 1: twoIntP.Put(data)
        Jorropo . resolved

        Any reason to not `defer` it when you `.Get` it ?

        allocz

        Acknowledged

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Mateusz Poliwczak
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 3
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-Reviewer: allocz <all...@gmail.com>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Attention: Alan Donovan <adon...@google.com>
        Gerrit-Comment-Date: Thu, 28 May 2026 17:26:17 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
        Comment-In-Reply-To: Jorropo <jorro...@gmail.com>
        Comment-In-Reply-To: Alan Donovan <adon...@google.com>
        unsatisfied_requirement
        open
        diffy

        Mateusz Poliwczak (Gerrit)

        unread,
        May 28, 2026, 1:36:50 PMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Robert Griesemer and allocz

        Mateusz Poliwczak added 1 comment

        File src/math/big/int.go
        Mateusz Poliwczak
        ```
        [mateusz@arch go ((4a1da811b9...))]$ benchstat /tmp/before /tmp/after

        goos: linux
        goarch: amd64
        pkg: math/big
        cpu: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
        │ /tmp/before │ /tmp/after │
        │ sec/op │ sec/op vs base │
        ModInverse-8 342.7n ± 1% 337.8n ± 1% -1.43% (p=0.000 n=25)
        ```

        On my system a reverse thing happens, but since it is a low difference i am fine.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Robert Griesemer
        • allocz
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Attention: Alan Donovan <adon...@google.com>
        Gerrit-Attention: allocz <all...@gmail.com>
        Gerrit-Comment-Date: Thu, 28 May 2026 17:36:41 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
        Comment-In-Reply-To: Alan Donovan <adon...@google.com>
        Comment-In-Reply-To: allocz <all...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        May 28, 2026, 1:45:57 PMMay 28
        to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Robert Griesemer and allocz

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #4 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Robert Griesemer
        • allocz
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 4
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Alan Donovan (Gerrit)

        unread,
        May 28, 2026, 1:57:37 PMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Jorropo, Robert Griesemer and allocz

        Alan Donovan voted and added 1 comment

        Votes added by Alan Donovan

        Hold+1

        1 comment

        File src/math/big/int.go
        Line 837, Patchset 3:func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . unresolved
        Alan Donovan

        Please document that the purpose of the optimization is to recycle limbs, not just Int variables.

        Even if you keep the SetInt64 operations in Put, you can still remove the indirection from *Int, which should reduce allocation, improve locality, and simplify the New function.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Jorropo
        • Robert Griesemer
        • allocz
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 4
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Attention: allocz <all...@gmail.com>
        Gerrit-Comment-Date: Thu, 28 May 2026 17:57:33 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        May 28, 2026, 2:02:38 PMMay 28
        to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Robert Griesemer and allocz

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #5 to this change.
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Robert Griesemer
        • allocz
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 5
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        unsatisfied_requirement
        open
        diffy

        Jorropo (Gerrit)

        unread,
        May 28, 2026, 2:18:33 PMMay 28
        to allocz, Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Robert Griesemer and allocz

        Jorropo voted and added 1 comment

        Votes added by Jorropo

        Hold+1

        1 comment

        Patchset-level comments
        allocz . resolved

        The code fixes the main issue that is allocations in hot loops. Looks good to me.

        Jorropo

        You can't review your own patches 😐

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Robert Griesemer
        • allocz
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 5
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Attention: Alan Donovan <adon...@google.com>
        Gerrit-Attention: allocz <all...@gmail.com>
        Gerrit-Comment-Date: Thu, 28 May 2026 18:18:27 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: allocz <all...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        Gerrit Bot (Gerrit)

        unread,
        May 28, 2026, 2:22:04 PMMay 28
        to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Robert Griesemer and allocz

        Gerrit Bot uploaded new patchset

        Gerrit Bot uploaded patch set #6 to this change.
        Following approvals got outdated and were removed:
        • Code-Review: +1 by allocz
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Robert Griesemer
        • allocz
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: newpatchset
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 6
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        unsatisfied_requirement
        open
        diffy

        allocz (Gerrit)

        unread,
        May 28, 2026, 2:22:54 PMMay 28
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo and Robert Griesemer

        allocz voted and added 1 comment

        Votes added by allocz

        Code-Review+1

        1 comment

        File src/math/big/int.go
        allocz

        Ok, I reduced the indirection `*[N]Int` instead of `*[N]*Int` and also added comments in the `ModInverse` and `lehmerGCD` procedures, explaining that the reason of the Int recycling is to reuse the limbs, which reduces allocations.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Robert Griesemer
        Submit Requirements:
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Holds
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedNo-Wait-Release
        • requirement is not satisfiedReview-Enforcement
        • requirement is not satisfiedTryBots-Pass
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
        Gerrit-Change-Number: 783861
        Gerrit-PatchSet: 4
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Alan Donovan <adon...@google.com>
        Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
        Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
        Gerrit-CC: Filippo Valsorda <fil...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
        Gerrit-CC: Roland Shoemaker <rol...@golang.org>
        Gerrit-CC: allocz <all...@gmail.com>
        Gerrit-Attention: Jorropo <jorro...@gmail.com>
        Gerrit-Attention: Robert Griesemer <g...@golang.org>
        Gerrit-Attention: Alan Donovan <adon...@google.com>
        Gerrit-Comment-Date: Thu, 28 May 2026 18:22:51 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        unsatisfied_requirement
        open
        diffy

        allocz (Gerrit)

        unread,
        May 28, 2026, 2:30:16 PMMay 28
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Alan Donovan, Mateusz Poliwczak, golang...@luci-project-accounts.iam.gserviceaccount.com, Jorropo, Robert Griesemer, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Alan Donovan, Jorropo, Mateusz Poliwczak and Robert Griesemer

        allocz added 3 comments

        Patchset-level comments
        File-level comment, Patchset 1:
        Gopher Robot . resolved

        I spotted some possible problems with your PR:

          1. The first word in the commit title after the package should be a lowercase English word (usually a verb).
        2. You have a long 205 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
        3. It looks like you are using markdown in the commit message. If so, please remove it. Be sure to double-check the plain text shown in the Gerrit commit message above for any markdown backticks, markdown links, or other markdown formatting.
        4. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

        Please address any problems by updating the GitHub PR.

        When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

        To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

        For more details, see:

        (In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

        allocz . resolved

        The code fixes the main issue that is allocations in hot loops. Looks good to me.

        Jorropo

        You can't review your own patches 😐

        allocz

        Sorry, my bad.

        File src/math/big/int.go
        Line 837, Patchset 3:func (t *sixIntPool) Put(data *[6]*Int) {
        Mateusz Poliwczak . resolved
        allocz

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Alan Donovan
        • Jorropo
        • Mateusz Poliwczak
        • Robert Griesemer
        Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Holds
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedNo-Wait-Release
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
          Gerrit-Change-Number: 783861
          Gerrit-PatchSet: 6
          Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
          Gerrit-Reviewer: Alan Donovan <adon...@google.com>
          Gerrit-Reviewer: Jorropo <jorro...@gmail.com>
          Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
          Gerrit-CC: Filippo Valsorda <fil...@golang.org>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-CC: Roland Shoemaker <rol...@golang.org>
          Gerrit-CC: allocz <all...@gmail.com>
          Gerrit-Attention: Mateusz Poliwczak <mpoliw...@gmail.com>
          Gerrit-Attention: Jorropo <jorro...@gmail.com>
          Gerrit-Attention: Robert Griesemer <g...@golang.org>
          Gerrit-Attention: Alan Donovan <adon...@google.com>
          Gerrit-Comment-Date: Thu, 28 May 2026 18:30:11 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Mateusz Poliwczak <mpoliw...@gmail.com>
          Comment-In-Reply-To: Jorropo <jorro...@gmail.com>
          Comment-In-Reply-To: Gopher Robot <go...@golang.org>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Gerrit Bot (Gerrit)

          unread,
          Jun 26, 2026, 3:40:31 PM (15 hours ago) Jun 26
          to allocz, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Alan Donovan, Jorropo, Mateusz Poliwczak and Robert Griesemer

          Gerrit Bot uploaded new patchset

          Gerrit Bot uploaded patch set #7 to this change.
          Open in Gerrit

          Related details

          Attention is currently required from:
          • Alan Donovan
          • Jorropo
          • Mateusz Poliwczak
          • Robert Griesemer
          Submit Requirements:
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Holds
          • requirement satisfiedNo-Unresolved-Comments
          • requirement is not satisfiedNo-Wait-Release
          • requirement is not satisfiedReview-Enforcement
          • requirement is not satisfiedTryBots-Pass
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: newpatchset
          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I152f208ebe11c8fb56352ed685920f827131bef3
          Gerrit-Change-Number: 783861
          Gerrit-PatchSet: 7
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages