]> Cypherpunks repositories - gostls13.git/commit
runtime: add specialized malloc functions for sizes up to 512 bytes
authorMichael Matloob <matloob@golang.org>
Mon, 17 Mar 2025 15:45:52 +0000 (11:45 -0400)
committerMichael Matloob <matloob@golang.org>
Wed, 24 Sep 2025 04:34:36 +0000 (21:34 -0700)
commit411c250d64304033181c46413a6e9381e8fe9b82
treedb1375c69b0d084fbc71fcd10c3ea86de5856f5f
parentd7a38adf4c81f0fa83203e37844192182b22680a
runtime: add specialized malloc functions for sizes up to 512 bytes

This CL adds a generator function in runtime/_mkmalloc to generate
specialized mallocgc functions for sizes up throuht 512 bytes. (That's
the limit where it's possible to end up in the no header case when there
are scan bits, and where the benefits of the specialized functions
significantly diminish according to microbenchmarks). If the
specializedmalloc GOEXPERIMENT is turned on, mallocgc will call one of
these functions in the no header case.

malloc_generated.go is the generated file containing the specialized
malloc functions.

malloc_stubs.go contains the templates that will be stamped to create
the specialized malloc functions.

malloc_tables_generated contains the tables that mallocgc will use to
select the specialized function to call.

I've had to update the two stdlib_test.go files to account for the new
submodule mkmalloc is in. mprof_test accounts for the changes in the
stacks since different functions can be called in some cases.
I still need to investigate heapsampling.go.

Change-Id: Ia0f68dccdf1c6a200554ae88657cf4d686ace819
Reviewed-on: https://go-review.googlesource.com/c/go/+/665835
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
15 files changed:
src/cmd/compile/internal/types2/stdlib_test.go
src/go/types/stdlib_test.go
src/internal/runtime/gc/sizeclasses.go
src/runtime/_mkmalloc/constants.go [new file with mode: 0644]
src/runtime/_mkmalloc/go.mod [new file with mode: 0644]
src/runtime/_mkmalloc/go.sum [new file with mode: 0644]
src/runtime/_mkmalloc/mkmalloc.go [new file with mode: 0644]
src/runtime/_mkmalloc/mkmalloc_test.go [new file with mode: 0644]
src/runtime/_mkmalloc/mksizeclasses.go
src/runtime/malloc.go
src/runtime/malloc_generated.go [new file with mode: 0644]
src/runtime/malloc_stubs.go [new file with mode: 0644]
src/runtime/malloc_tables_generated.go [new file with mode: 0644]
src/runtime/malloc_tables_plan9.go [new file with mode: 0644]
src/runtime/malloc_test.go