[go] runtime: consolidate tiny sizespecializedmalloc functions

2 views
Skip to first unread message

Michael Matloob (Gerrit)

unread,
May 11, 2026, 5:06:45 PM (7 hours ago) May 11
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
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>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages