-
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: Allocations leak into outer scope #39514
Comments
/cc @mdempsky |
(I'm assuming that in your actual application the In BadOperation, the call to The
|
Yes, exactly! Thanks for the detailed explanation! It helped me to figure out how to work around this -- in this case, I took a copy of the Three pretty small changes (three commits ending with that one) reduced the allocations dramatically. As far as I'm concerned, this ticket can be closed (unless you want it to remain open since " there's arguably room for improvement") |
Change https://golang.org/cl/262937 mentions this issue: |
@cuonglm found a fix for this in CL 262937, but it appears to not help real world Go code much. E.g., k8s.io/kubernetes/cmd/kubelet is only able to stack allocate one new variable. Right now, the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe I'm on the latest release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I hit a strange issue while doing some benchmarking in go-ethereum . It turned out that the allocations for a particular operation went through the roof, for no good reason as far as I could tell.
I narrowed down the problem as best I could. this gist contains a tiny VM + benchmarking code which shows two cases: one where allocations are made for a branch that is never taken, and another where the unused branch is commented out, and allocations are "sane".
It's quite a difference:
What did you expect to see?
That allocations inside a scope which was never entered are not made.
What did you see instead?
That allocations seems to be done outside the scope, directly after the entry into the method.
The text was updated successfully, but these errors were encountered: