-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: insertVarPhis is very slow #17926
Comments
This is a difficult problem. I would love to have a phi placement algorithm that ran in O(n) time in the size of the minimal output, full stop. I don't think such a thing is known to exist. I've been thinking about how to avoid placing phis outside the union of the subtrees dominated by the variable definitions. It would probably help this case. Definitely not for 1.8 though. |
CL https://golang.org/cl/33305 mentions this issue. |
Algorithmic improvements here are hard. Lifting a lookup out of the loop helps a little, though. To compile the code in #17926: name old s/op new s/op delta Real 146 ± 3% 140 ± 4% -3.87% (p=0.002 n=10+10) User 143 ± 3% 139 ± 4% -3.08% (p=0.005 n=10+10) Sys 8.28 ±35% 8.08 ±28% ~ (p=0.684 n=10+10) Updates #17926. Change-Id: Ic255ac8b7b409c1a53791058818b7e2cf574abe3 Reviewed-on: https://go-review.googlesource.com/33305 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
@randall77 Might be interesting: |
We use that algorithm for smaller functions. It has bad behavior for certain classes of large functions (lots of variables and long chains of diamond control flows). |
go version devel +b687d6a Tue Nov 15 05:35:54 2016 +0000 linux/amd64
My real package takes 30+ seconds to compile.
Using program generator below:
With 500 iterations:
compilation time 0.79s
phiState.insertVarPhis takes 8.27%
With 1000 iterations:
compilation time 1.54s
phiState.insertVarPhis takes 11.84%
With 2000 iterations:
compilation time 3.65s
phiState.insertVarPhis takes 15.75%
With 4000 iterations:
compilation time 10.63s
phiState.insertVarPhis takes 20.94%
With 8000 iterations:
compilation time 26.03s
phiState.insertVarPhis takes 32.16%
With 16000 iterations:
compilation time 101.91s
phiState.insertVarPhis takes 53.08%
insertVarPhis executes inner loop millions of times without doing anything (variable is dead)
compile also consumes 5GB of memory (150KB per statement), which causes compilation on weak VM to never succeed due to OOM kills
Please make it faster and consume less memory.
The text was updated successfully, but these errors were encountered: