cmd/compile/internal/escape: performance issue #67313
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
ToolSpeed
Milestone
Go version
go version go1.22.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Repo with full repro and pprof profiles: https://github.com/podtserkovskiy/go-slow-escape
We have a Go package generated from a large thrift file
Bad.thrift
bygb.xjqchip.workers.dev/facebook/fbthrift
codegen.The
Bad.thrift
file has ~12k significant lines of code and generated Go package has ~924k significant lines of code.It takes 43 minutes for
cmd/compile
to compile it, which seems to be reasonable until we start to compare it with other files.We have another big thrift file
Good.thrift
, it has ~11k significant lines of code and generated Go package has ~737k significant lines of code.However it takes just 4 minutes to compile this Go package.
The key difference between these files is that
Bad.thrift
structures is more interconnected thanGood.thrift
.The compilation time of
Bad.thrift
expected to be a bit longer thanGood.thrift
, but 39 min difference (10x!) looks suspicious.What did you see happen?
My next step after discovering this facts was adding
-cpuprofile
flag tocmd/compile
and the results look very interesting.The compiler spends ~74% of time in
cmd/compile/internal/escape.Funcs
when processingBad.thrift
.However
Good.thrift
's profile looks completely different, it spends majority of time inssagen.Compile
instead.SVG files for both
Bad.thrift
svg andGood.thrift
svg are attached.The raw pprof profile files are there
good.cpu
andbad.cpu
.What did you expect to see?
That makes me think we hit a performance bottleneck there.
I would be really grateful if somebody familiar with this part of the compiler can take a look on this issue 🙏
The text was updated successfully, but these errors were encountered: