-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed as not planned
Closed as not planned
@fxrlv Output of
Description
Go version
go version go1.25.0 darwin/arm64
Output of go env
in your module/workspace:
AR='ar' CC='cc' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_ENABLED='1' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' CXX='c++' GCCGO='gccgo' GO111MODULE='' GOARCH='arm64' GOARM64='v8.0' GOAUTH='netrc' GOBIN='' GOCACHE='/Users/fxrlv/Library/Caches/go-build' GOCACHEPROG='' GODEBUG='' GOENV='/Users/fxrlv/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFIPS140='off' GOFLAGS='' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/mg/1l0261p97kzflrmx68mm4z7c0000gn/T/go-build272519646=/tmp/go-build -gno-record-gcc-switches -fno-common' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMOD='/tmp/kxe/go.mod' GOMODCACHE='/Users/fxrlv/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/fxrlv/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.25.0/libexec' GOSUMDB='sum.golang.org' GOTELEMETRY='on' GOTELEMETRYDIR='/Users/fxrlv/Library/Application Support/go/telemetry' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.0/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.25.0' GOWORK='' PKG_CONFIG='pkg-config'
What did you do?
Allocating a new slice trying to hit the per-P cache
package main const MaxSmallSize = 32768 // https://github.com/golang/go/blob/go1.25.0/src/internal/runtime/gc/sizeclasses.go#L86 const MallocHeaderSize = 8 // https://github.com/golang/go/blob/go1.25.0/src/internal/runtime/gc/malloc.go#L16 func main() { var b []byte b = append(b, make([]byte, MaxSmallSize-MallocHeaderSize)...) print(cap(b)) // 32768 }
What did you see happen?
growslice
uses mallocgcLarge
to allocate from the heap
What did you expect to see?
growslice
treats the allocation as the small objects' allocation using mallocgcSmallNoscan