[go] runtime: consolidate tiny sizespecializedmalloc functions

6 views
Skip to first unread message

Michael Matloob (Gerrit)

unread,
Apr 30, 2026, 3:30:30 PM (11 days ago) Apr 30
to goph...@pubsubhelper.golang.org, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Michael Pratt

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
Gerrit-Change-Number: 772540
Gerrit-PatchSet: 3
Gerrit-Owner: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Michael Knyszek <mkny...@google.com>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Thu, 30 Apr 2026 19:30:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Matloob (Gerrit)

unread,
Apr 30, 2026, 4:53:11 PM (11 days ago) Apr 30
to Michael Matloob, goph...@pubsubhelper.golang.org, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
Attention needed from Michael Matloob and Michael Pratt

Michael Matloob voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Michael Matloob
  • Michael Pratt
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
Gerrit-Change-Number: 772540
Gerrit-PatchSet: 3
Gerrit-Owner: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@google.com>
Gerrit-Attention: Michael Matloob <mat...@golang.org>
Gerrit-Attention: Michael Pratt <mpr...@google.com>
Gerrit-Comment-Date: Thu, 30 Apr 2026 20:53:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Michael Pratt (Gerrit)

unread,
May 6, 2026, 3:07:36 PM (5 days ago) May 6
to Michael Matloob, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Michael Pratt, golang-co...@googlegroups.com
Attention needed from Michael Matloob

Michael Pratt added 6 comments

Commit Message
Line 16, Patchset 6 (Latest):function was slower.
Michael Pratt . unresolved

trailing whitespace

Line 18, Patchset 6 (Latest):Look at the change description of CL 766980 for the results of those
Michael Pratt . unresolved

IIUC, these results compare tiny allocations with specialized malloc today vs consolidated specialized malloc (this CL).

How do they compare against no specialized malloc (GOEXPERIMENT=nosizespecializedmalloc)? I assume that they are still faster?

File src/runtime/_mkmalloc/mkmalloc.go
Line 634, Patchset 6 (Latest): if i < 16 {
Michael Pratt . unresolved

See comment in malloc_table_generated.go. I think we still want to emit panic for size 0?

File src/runtime/malloc_generated.go
Line 4381, Patchset 6 (Latest):func mallocgcTinySC2(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
Michael Pratt . resolved

It's nice that we can easily see the actual diff here 😄

Line 4417, Patchset 6 (Latest): if size&7 == 0 {
off = alignUp(off, 8)
} else if goarch.PtrSize == 4 && size == 12 {

off = alignUp(off, 8)
} else if size&3 == 0 {
off = alignUp(off, 4)
} else if size&1 == 0 {
off = alignUp(off, 2)
}
Michael Pratt . resolved

I'd assume that the only real difference in microbenchmarks is that previously these branches would be eliminated, leaving exactly the right alignUp call.

The other uses below go from add/compare of register and immediate to register and register, which I'd guess is negligible.

File src/runtime/malloc_tables_generated.go
Line 525, Patchset 6 (Parent): mallocPanic,
Michael Pratt . unresolved

Why did this go away?

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Matloob
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: I824f65727a858158c14d2edd6fea1e846a6a6964
    Gerrit-Change-Number: 772540
    Gerrit-PatchSet: 6
    Gerrit-Owner: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-CC: Michael Knyszek <mkny...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Wed, 06 May 2026 19:07:30 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 6, 2026, 5:54:42 PM (5 days ago) May 6
    to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Michael Pratt, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob added 3 comments

    Commit Message
    Line 16, Patchset 6:function was slower.
    Michael Pratt . resolved

    trailing whitespace

    Michael Matloob

    Done

    File src/runtime/_mkmalloc/mkmalloc.go
    Line 634, Patchset 6: if i < 16 {
    Michael Pratt . resolved

    See comment in malloc_table_generated.go. I think we still want to emit panic for size 0?

    Michael Matloob

    Done

    File src/runtime/malloc_tables_generated.go
    Michael Pratt . resolved

    Why did this go away?

    Michael Matloob

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    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: I824f65727a858158c14d2edd6fea1e846a6a6964
    Gerrit-Change-Number: 772540
    Gerrit-PatchSet: 7
    Gerrit-Owner: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-CC: Michael Knyszek <mkny...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@google.com>
    Gerrit-Attention: Michael Pratt <mpr...@google.com>
    Gerrit-Comment-Date: Wed, 06 May 2026 21:54:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 6, 2026, 5:54:42 PM (5 days ago) May 6
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob uploaded new patchset

    Michael Matloob uploaded patch set #7 to this change.
    Following approvals got outdated and were removed:
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    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: newpatchset
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 6, 2026, 6:00:26 PM (5 days ago) May 6
    to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Michael Pratt, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob added 1 comment

    Commit Message
    Line 18, Patchset 6:Look at the change description of CL 766980 for the results of those
    Michael Pratt . unresolved

    IIUC, these results compare tiny allocations with specialized malloc today vs consolidated specialized malloc (this CL).

    How do they compare against no specialized malloc (GOEXPERIMENT=nosizespecializedmalloc)? I assume that they are still faster?

    Michael Matloob

    I need to look at this more. They are faster when invoked directly, but not anymore through the jump table. I'm going to see if I can skip the jump table in the tiny case.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    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: I824f65727a858158c14d2edd6fea1e846a6a6964
    Gerrit-Change-Number: 772540
    Gerrit-PatchSet: 7
    Gerrit-Owner: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-Reviewer: Michael Matloob <mat...@google.com>
    Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
    Gerrit-CC: Michael Knyszek <mkny...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@google.com>
    Gerrit-Attention: Michael Pratt <mpr...@google.com>
    Gerrit-Comment-Date: Wed, 06 May 2026 22:00:21 +0000
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 7, 2026, 11:35:24 AM (4 days ago) May 7
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob uploaded new patchset

    Michael Matloob uploaded patch set #8 to this change.
    Following approvals got outdated and were removed:
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    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: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I824f65727a858158c14d2edd6fea1e846a6a6964
    Gerrit-Change-Number: 772540
    Gerrit-PatchSet: 8
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 7, 2026, 12:03:12 PM (4 days ago) May 7
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob uploaded new patchset

    Michael Matloob uploaded patch set #9 to this change.
    Following approvals got outdated and were removed:
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    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: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I824f65727a858158c14d2edd6fea1e846a6a6964
    Gerrit-Change-Number: 772540
    Gerrit-PatchSet: 9
    unsatisfied_requirement
    open
    diffy

    Michael Matloob (Gerrit)

    unread,
    May 7, 2026, 2:10:36 PM (4 days ago) May 7
    to goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Michael Pratt, golang-co...@googlegroups.com
    Attention needed from Michael Matloob and Michael Pratt

    Michael Matloob added 1 comment

    Commit Message
    Line 18, Patchset 6:Look at the change description of CL 766980 for the results of those
    Michael Pratt . resolved

    IIUC, these results compare tiny allocations with specialized malloc today vs consolidated specialized malloc (this CL).

    How do they compare against no specialized malloc (GOEXPERIMENT=nosizespecializedmalloc)? I assume that they are still faster?

    Michael Matloob

    I need to look at this more. They are faster when invoked directly, but not anymore through the jump table. I'm going to see if I can skip the jump table in the tiny case.

    Michael Matloob

    Okay, I was able to make a change to them so that they are now faster:

    ```
    goos: linux
    goarch: amd64
    pkg: runtime
    cpu: AMD Ryzen 9 9950X3D 16-Core Processor
    │ base │ sizespecializedmalloc │
    │ sec/op │ sec/op vs base │
    1 4.029n ± 2% 3.736n ± 1% -7.27% (p=0.000 n=10)
    2 4.048n ± 1% 3.595n ± 1% -11.17% (p=0.000 n=10)
    3 4.352n ± 1% 4.062n ± 1% -6.64% (p=0.000 n=10)
    4 4.485n ± 1% 4.277n ± 1% -4.64% (p=0.000 n=10)
    5 4.969n ± 1% 4.715n ± 1% -5.10% (p=0.000 n=10)
    6 5.800n ± 1% 5.234n ± 0% -9.77% (p=0.000 n=10)
    7 5.729n ± 1% 5.328n ± 0% -7.00% (p=0.000 n=10)
    8 5.390n ± 2% 5.173n ± 1% -4.02% (p=0.000 n=10)
    9 7.328n ± 1% 7.258n ± 1% -0.95% (p=0.015 n=10)
    10 7.362n ± 2% 7.125n ± 0% -3.22% (p=0.000 n=10)
    11 7.335n ± 1% 7.223n ± 1% -1.51% (p=0.001 n=10)
    12 7.068n ± 1% 7.072n ± 1% ~ (p=0.529 n=10)
    13 7.363n ± 2% 7.218n ± 1% -1.96% (p=0.001 n=10)
    14 7.347n ± 2% 7.082n ± 1% -3.61% (p=0.000 n=10)
    15 7.365n ± 1% 7.199n ± 1% -2.26% (p=0.002 n=10)
    geomean 5.843n 5.571n -4.66%
    ```

    i also checked the larger sizes to make sure that they weren't slower either since we made changes before the jump table

    ```
    goos: linux
    goarch: amd64
    pkg: runtime
    cpu: AMD Ryzen 9 9950X3D 16-Core Processor
    │ base │ sizespecializedmalloc │
    │ sec/op │ sec/op vs base │
    1 4.029n ± 2% 3.736n ± 1% -7.27% (p=0.000 n=10)
    2 4.048n ± 1% 3.595n ± 1% -11.17% (p=0.000 n=10)
    3 4.352n ± 1% 4.062n ± 1% -6.64% (p=0.000 n=10)
    4 4.485n ± 1% 4.277n ± 1% -4.64% (p=0.000 n=10)
    5 4.969n ± 1% 4.715n ± 1% -5.10% (p=0.000 n=10)
    6 5.800n ± 1% 5.234n ± 0% -9.77% (p=0.000 n=10)
    7 5.729n ± 1% 5.328n ± 0% -7.00% (p=0.000 n=10)
    8 5.390n ± 2% 5.173n ± 1% -4.02% (p=0.000 n=10)
    9 7.328n ± 1% 7.258n ± 1% -0.95% (p=0.015 n=10)
    10 7.362n ± 2% 7.125n ± 0% -3.22% (p=0.000 n=10)
    11 7.335n ± 1% 7.223n ± 1% -1.51% (p=0.001 n=10)
    12 7.068n ± 1% 7.072n ± 1% ~ (p=0.529 n=10)
    13 7.363n ± 2% 7.218n ± 1% -1.96% (p=0.001 n=10)
    14 7.347n ± 2% 7.082n ± 1% -3.61% (p=0.000 n=10)
    15 7.365n ± 1% 7.199n ± 1% -2.26% (p=0.002 n=10)
    geomean 5.843n 5.571n -4.66%
    ```
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Matloob
    • Michael Pratt
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
      Gerrit-Change-Number: 772540
      Gerrit-PatchSet: 9
      Gerrit-Owner: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@google.com>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-CC: Michael Knyszek <mkny...@google.com>
      Gerrit-Attention: Michael Matloob <mat...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      Gerrit-Comment-Date: Thu, 07 May 2026 18:10:33 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Michael Matloob <mat...@golang.org>
      Comment-In-Reply-To: Michael Pratt <mpr...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Michael Matloob (Gerrit)

      unread,
      May 8, 2026, 4:28:47 PM (3 days ago) May 8
      to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Michael Pratt

      Michael Matloob uploaded new patchset

      Michael Matloob uploaded patch set #10 to this change.
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Pratt
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
      Gerrit-Change-Number: 772540
      Gerrit-PatchSet: 10
      Gerrit-Owner: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@google.com>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-CC: Michael Knyszek <mkny...@google.com>
      Gerrit-Attention: Michael Pratt <mpr...@google.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Michael Pratt (Gerrit)

      unread,
      5:06 PM (6 hours ago) 5:06 PM
      to Michael Matloob, goph...@pubsubhelper.golang.org, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, golang-co...@googlegroups.com
      Attention needed from Michael Matloob

      Michael Pratt voted Code-Review+2

      Code-Review+2
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
      Gerrit-Change-Number: 772540
      Gerrit-PatchSet: 13
      Gerrit-Owner: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Reviewer: Michael Matloob <mat...@google.com>
      Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
      Gerrit-CC: Michael Knyszek <mkny...@google.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Comment-Date: Mon, 11 May 2026 21:06:01 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Michael Matloob (Gerrit)

      unread,
      5:06 PM (6 hours ago) 5:06 PM
      to Michael Matloob, goph...@pubsubhelper.golang.org, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com
      Attention needed from Michael Matloob

      Michael Matloob voted Code-Review+1

      Code-Review+1
      Open in Gerrit

      Related details

      Attention is currently required from:
      • Michael Matloob
      Submit Requirements:
        • requirement satisfiedCode-Review
        • requirement satisfiedNo-Unresolved-Comments
        • requirement satisfiedReview-Enforcement
        • requirement 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: I824f65727a858158c14d2edd6fea1e846a6a6964
        Gerrit-Change-Number: 772540
        Gerrit-PatchSet: 13
        Gerrit-Owner: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
        Gerrit-Reviewer: Michael Matloob <mat...@google.com>
        Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
        Gerrit-CC: Michael Knyszek <mkny...@google.com>
        Gerrit-Attention: Michael Matloob <mat...@golang.org>
        Gerrit-Comment-Date: Mon, 11 May 2026 21:06:26 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy

        Michael Matloob (Gerrit)

        unread,
        5:06 PM (6 hours ago) 5:06 PM
        to Michael Matloob, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Knyszek, golang-co...@googlegroups.com

        Michael Matloob submitted the change

        Change information

        Commit message:
        runtime: consolidate tiny sizespecializedmalloc functions

        In the sizespecializedmalloc goexperiment, we specialized the tiny
        function per tiny size, so there was a different allocation function per
        size from 1-15. This created a lot of functions for a code path that was
        not executed that often. From the microbenchmarks, comparing the
        consolidated tiny function in this cl with the per-size functions, the
        specialized functions could be up to 20% faster, but for 8 byte
        allocations, which are almost certainly the most common, the per-size
        function was slower.


        Look at the change description of CL 766980 for the results of those
        microbenchmarks. The CL also contains the code used to run the
        benchmark.

        Since we've noticed significant icache pressure from all the functions,
        and, the tiny functions aren't used as much as the other ones, and the
        benefits seem to be mixed, consolidate the 15 functions into a single
        function.

        This cuts the size of the mallocgc* functions by about 20%.

        For #79286
        Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64_c2s16-perf_vs_parent-sizespecializedmalloc,gotip-linux-amd64_c3h88-perf_vs_parent-sizespecializedmalloc,gotip-linux-arm64_c4ah72-perf_vs_parent-sizespecializedmalloc,gotip-linux-arm64_c4as16-perf_vs_parent-sizespecializedmalloc,gotip-linux-arm64_c4as16-perf_vs_parent,gotip-linux-arm64_c4ah72-perf_vs_parent,gotip-linux-amd64_c3h88-perf_vs_parent,gotip-linux-amd64_c2s16-perf_vs_parent
        Change-Id: I824f65727a858158c14d2edd6fea1e846a6a6964
        Reviewed-by: Michael Matloob <mat...@google.com>
        Reviewed-by: Michael Pratt <mpr...@google.com>
        Files:
        • M src/cmd/compile/internal/ir/symtab.go
        • M src/cmd/compile/internal/ssa/rewrite.go
        • M src/cmd/compile/internal/ssagen/ssa.go
        • M src/runtime/_mkmalloc/mkmalloc.go
        • M src/runtime/malloc.go
        • M src/runtime/malloc_generated.go
        • M src/runtime/malloc_stubs.go
        • M src/runtime/malloc_tables_generated.go
        • M test/codegen/strings.go
        • M test/live.go
        • M test/live_regabi.go
        Change size: XL
        Delta: 11 files changed, 101 insertions(+), 2277 deletions(-)
        Branch: refs/heads/master
        Submit Requirements:
        Open in Gerrit
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: merged
        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I824f65727a858158c14d2edd6fea1e846a6a6964
        Gerrit-Change-Number: 772540
        Gerrit-PatchSet: 14
        open
        diffy
        satisfied_requirement
        Reply all
        Reply to author
        Forward
        0 new messages