New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: compileSSA takes a long time on very large (generated) functions #30077
Comments
Correction, 'go build' took many minutes but did finish eventually. |
You say that the build consumes “all the CPU” — exactly which process is it that is stuck? (Is it the compiler, the linker, or something else?) |
Finally, why is this particular generated file important, and how much control do you have over the generator? It's almost always possible to build an adversarial input to a compiler, so sometimes it's easier to fix the generator to avoid pathological cases than to fix the compiler to handle them efficiently. |
This is the process consuming CPU:
Well, I control the code generator. If I find what is the pathological case for the Go compiler, I can avoid it. Not sure if it should be simple to paste 44k line Go file to Playground, but I am failing at it. |
Are you generating very large functions by any chance? I've seen situations where that makes SSA terribly slow, since you essentially create massive scopes for it to take care of. If that's the case, you could try splitting large functions into pieces, and calling all of those. |
Yes, main() is one single huge function. |
CC @randall77 |
The offending code has been located, I guess. Generated code had multiple large 'switch' statements like this:
I reworked code generation to issue a single large 'switch' statment, and jump into it as needed. Compilation is much faster now. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
$ go build a.go
a.go is machine-genrated Go code:
a.zip
What did you expect to see?
go build should finish eventually.
What did you see instead?
go build consuming all the CPU and never finishes.
The text was updated successfully, but these errors were encountered: