go/ssa: skip Selection.Type in MethodValue for non-generic methods - #674
Open
hungcs wants to merge 1 commit into
Open
go/ssa: skip Selection.Type in MethodValue for non-generic methods#674hungcs wants to merge 1 commit into
hungcs wants to merge 1 commit into
Conversation
When a method has no type parameters of its own, substituting a ground receiver cannot introduce free type parameters, so the selection type is parameterized iff the receiver is, and the receiver-only check suffices. Only generic methods need the full check on the materialized (and canonicalized, see CL 826224) selection type. Selection.Type allocates a new Signature on every call, and MethodValue runs for every (type, method) pair the method-set machinery reaches, so on large programs the allocation churn is significant GC load: on a 1,132-package monorepo with no generic methods, whole-program analysis drops from 296s to 210s wall (findings identical), close to the 186s that x/tools v0.45.0 needed before generic-method support. Updates golang/go#81308
Contributor
|
This PR (HEAD: dbdd830) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/827325. Important tips:
|
Contributor
|
Message from Hung-wei Chuang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/827325. |
Contributor
|
Message from Hung-wei Chuang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/827325. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to CL 826224 (the #81308 memory fix). That fix stopped the
per-selection Signatures from being retained, but they were still allocated:
MethodValue materializes sel.Type() for every (type, method) pair, and on
large programs the churn is real GC load.
When the method has no type parameters of its own, a ground receiver can't
leave free type parameters in the selection type, so the receiver-only check
is equivalent and nothing needs to be materialized. Generic methods keep the
full canonicalized check.
Makes deadcode ~8% faster on a benchmark of kubernetes/cmd/kubelet
(7.15s to 6.55s)
Updates golang/go#81308