-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: improve escape analysis fidelity #33981
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
Comments
Change https://golang.org/cl/193178 mentions this issue: |
Change https://golang.org/cl/193177 mentions this issue: |
Change https://golang.org/cl/193179 mentions this issue: |
A little disappointing, but it looks like this only really helps cmd/compile/internal/gc.substArgTypes; in particular, the ... argument no longer escapes to the heap. So the ~30 call sites all benefit. This is because the improved fidelity for cmd/compile/internal/types.SubstAny (used by gc.substArgTypes) can now report that for the It also allows a few maps to be stack allocated in pprof:
|
Building all of Kubernetes (go build k8s.io/kubernetes/...) yields slightly better results; 145 improvements in total. 145 escape analysis improvements
|
No behavior change; just inverting the loop ordering so the per-parameter behavior is a bit clearer. Passes toolstash-check. Updates #33981. Change-Id: I9bfcd7d0a4aff65a27ced157767ca2ba8038319a Reviewed-on: https://go-review.googlesource.com/c/go/+/193177 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This CL moves parameter tagging to before escape analysis is complete, so we still have access to EscLocation. This will be useful once EscLocation starts tracking higher-fidelity escape details. Notably, this CL stops using n.Esc to record parameter escape analysis details. Now escape analysis only ever sets n.Esc to EscNone or EscHeap. (It still defaults to EscUnknown, and is set to EscNever in some places though.) Passes toolstash-check. Updates #33981. Change-Id: I50a91ea1e38c442092de6cd14e20b211f8f818c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/193178 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Change https://golang.org/cl/197679 mentions this issue: |
Change https://golang.org/cl/197680 mentions this issue: |
This CL better abstracts away the parameter leak info that was directly encoded into the uint16 value. Followup CL will rewrite the implementation. Passes toolstash-check. Updates #33981. Change-Id: I27f81d26f5dd2d85f5b0e5250ca529819a1f11c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/197679 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Currently, when compiling the test case below, escape analysis decides that both
i
andj
escape and need to be heap allocated. However, actually onlyi
escapes;j
is safe to stack allocate.The reason for this is that the escape analysis tags use a single-bit flag
EscContentEscapes
to mark if anything pointed to by a parameter escape to the heap; so callers can't distinguishg = **p
fromg = *p
.Contrast with how
escapeReturnEncoding
uses multiple bits to store a fixnum value, so it can distinguishreturn p
,return *p
,return **p
, etc.Moreover, while we currently track these values in a
uint16
during escape analysis, they're eventually converted to strings and serialized in export data as strings, so the 16-bits constrained is self-imposed.The text was updated successfully, but these errors were encountered: