Func.Names was []*LocalSlot, so every entry was a separately heap-allocated LocalSlot. Most named values are scalars that are never decomposed, yet each one still allocated a LocalSlot when it was first recorded in addNamedValue. Change Func.Names to []LocalSlot. addNamedValue now appends the slot by value and no longer eagerly fills CanonicalLocalSlots. The canonical *LocalSlot used for SplitOf chains and split deduplication is created lazily by localSlotAddr, so only slots that are actually decomposed pay for it. The names stay contiguous and the garbage collector has one fewer pointer per name to scan. This is a follow-up to CL 790300, the addNamedValue escape fix for issue #79990. That change stopped the slot escaping; this one removes the remaining per-name allocation for slots that are never decomposed. Passes toolstash -cmp; std and cmd build byte-identical. allocs/op via compilebench -alloc, linux/amd64 (-count 20); all packages ±0%, p<=0.001. "vs parent" is the win over CL 790300, "vs master" folds in CL 790300 too: allocs/op vs parent vs master Template 814.0k -0.16% -0.76% Unicode 573.7k -0.03% -0.10% GoTypes 4.956M -0.26% -1.08% SSA 46.32M -0.37% -1.51% Flate 811.6k -0.30% -1.45% GoParser 785.8k -0.23% -0.78% Reflect 2.293M -0.41% -1.11% Tar 927.5k -0.34% -1.02% XML 1.088M -0.32% -0.92% geomean 1.755M -0.27% -0.97% Updates #79990 Change-Id: Ib277056a47585d7805438955062c2f59bd77d42f Reviewed-on: https://go-review.googlesource.com/c/go/+/790920 Reviewed-by: Michael Podtserkovskii <michaelpo@meta.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.