Skip to content

cmd/compile: slow escape analysis in large package in the typescript compiler #72815

Closed
@Jorropo

Description

@Jorropo

Go version

go version go1.24.1 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v3'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/tmp/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/hugo/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1913709825=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/hugo/k/go/src/go.mod'
GOMODCACHE='/home/hugo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/hugo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/hugo/k/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/hugo/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/hugo/k/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I've tried compiling the new typescript compiler and it took 70s:

________________________________________________________
Executed in   70.51 secs    fish           external
   usr time  159.17 secs  543.00 micros  159.17 secs
   sys time    5.49 secs  249.00 micros    5.49 secs

What tipped me off to an issue is the poor 160 ÷ 70 ≈ 2.3 multi-core utilization.

The biggest outlier is github.com/microsoft/typescript-go/internal/checker:

github.com/microsoft/typescript-go/internal/checker

________________________________________________________
Executed in   44.97 secs    fish           external
   usr time   50.51 secs  413.00 micros   50.51 secs
   sys time    0.32 secs  142.00 micros    0.32 secs

A CPU profile is very suspicious, almost all of the time is spent here:
Image

I've added a couple of debug statements in theses loops:
There is a suspicious:

walkAll 36466 <nil> <nil>

36466 is the length of the queue.
This steadily slowly goes down, walkOne roughly does ~5000 iterations for each iteration of walkAll

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OtherNone of the above.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions