runtime: improve performance of grow() in mheap.go #25091
Labels
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Performance
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +c5f0104 Wed Apr 25 21:34:15 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jerrin/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jerrin/gocode"
GORACE=""
GOROOT="/work/go"
GOTMPDIR=""
GOTOOLDIR="/work/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build042307601=/tmp/go-build -gno-record-gcc-switches"
What did you do?
When
grow()
inmheap.go
is called, it sets the span entry for every page in the newly created span. This seems unnecessary as the span is anyway going to be put into the free list/treap, and only the first and last span entry need be set for a free span. The following diff is a suggestion to improve this piece of code. The newly added code is similar to howallocSpanLocked()
inmheap.go
trims the extra pages and puts it back to the free list/treap.The text was updated successfully, but these errors were encountered: