Skip to content

cmd/go: under CPU/memory pressure, module indexing causes go list to run very slowly #80273

Description

@dvadas

What version of Go are you using (go version)?

$ go version
go version go1.25.11 darwin/arm64

Does this issue reproduce with the latest release?

I don't know.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
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/davidvadas/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/davidvadas/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/q5/gcfnff3j6sbcjcpz0pz9njdw0000gn/T/go-build1028563970=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/davidvadas/go/pkg/mod'
GONOPROXY='github.com,golang.org,googlesource.com,opentelemetry.io,uber.org'
GONOSUMDB='goms.io,*.goms.io'
GOOS='darwin'
GOPATH='/Users/davidvadas/go'
GOPRIVATE='goms.io,*.goms.io'
GOPROXY='https://goproxyprod.goms.io'
GOROOT='/opt/homebrew/Cellar/go@1.25/1.25.11/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/davidvadas/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go@1.25/1.25.11/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.11'
GOWORK=''
PKG_CONFIG='pkg-config'
uname -v: Darwin Kernel Version 24.6.0: Tue Apr 21 20:18:13 PDT 2026; root:xnu-11417.140.69.710.16~1/RELEASE_ARM64_T8132
ProductName:		macOS
ProductVersion:		15.7.7
BuildVersion:		24G720
lldb --version: lldb-1703.0.236.103
Apple Swift version 6.2.4 (swiftlang-6.2.4.1.4 clang-1700.6.4.2)

What did you do?

I was seeing very slow times to run go list on my machine. This occurred while my machine was under a fair bit of CPU/memory pressure, since I was running a bunch of local Kubernetes clusters (kind) at the time.

On macOS (Apple Silicon), with Go 1.25.11:

$ time go list -deps ./... > /dev/null

real	0m50.121s
user	0m1.063s
sys	0m2.612s

I sampled the process to see what it was doing:

$ go list -deps ./... >/dev/null &
$ pid=$!
$ sample "$pid" 10 -file /tmp/golist.sample
$ wait "$pid"

The sample contained frames such as:

cmd/go/internal/modindex.fromBytes
cmd/go/internal/modindex.decoder.stringTableAt
cmd/go/internal/modindex.Module.Package.func1
cmd/go/internal/modindex.openIndexPackage.func1
cmd/go/internal/load.loadPackageData
cmd/go/internal/modload.LoadPackages

Which suggests the slowdown is occuring in the modindex code: https://github.com/golang/go/blob/master/src/cmd/go/internal/modindex/read.go

And indeed, if the index is disabled then the command runs much faster:

$ time GODEBUG='#goindex=0' go list -deps ./... >/dev/null

real	0m13.408s
user	0m0.908s
sys	0m1.771s

What did you expect to see?

I expect the module index to be making go list run faster, not slower.

What did you see instead?

I saw go list running so slowly that it was bottlenecking gopls, causing unresponsiveness in VSCode.

For reference, here's some other go list commands and their timings:

$ time go list -m -json all > /dev/null

real	0m1.078s
user	0m0.056s
sys	0m0.121s

For the next one with std you can see the first invocation with no cache is much slower than the second run:

$ time go list std > /dev/null

real	1m45.571s
user	0m0.473s
sys	0m1.312s
$ time go list std > /dev/null

real	0m20.354s
user	0m0.263s
sys	0m0.759s

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performance

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions