Track const type information in a separate lattice element#44447
Closed
Track const type information in a separate lattice element#44447
Conversation
Introduces a spearate lattice elements for tracking const Types
that also stores the corresponding Type{} information, ensuring
that this is only computed once and whenever possible is taken
from an existing instance of it instead of recomputing it.
Part of #44402
Member
Author
|
Oh I guess I forgot the punch line. This makes inference 20% faster on my particular inference benchmark. |
vtjnash
reviewed
Mar 8, 2022
| (= (outerref ,name) ,name))) | ||
| (= (outerref ,name) ,name)) | ||
| (block | ||
| (call (core set_binding_type!) (thismodule) (inert ,name) (call (core apply_type) (core Type) ,name)) |
Member
|
IIUC, this was essentially replaced by #44704, before this one became badly conflicted |
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.
As mentioned in #44402,
widenconston aConstwhose value is aTypecan be quite slow - slow enough to show up noticeably in profiles. This attempts to address that by splitting theConstlattice element into two:ConstandConstType, the former being used for non-Typevalues and the latter being used forTypes, additionally tracking theType{T}for the constant typeT, thus saving the lookup on widenconst.Now, not every
Constactually passes through widenconst, which would cause a performance regression, but it turns out that mostConstTypes originate from global references. Thus, we can take advantage of the recently added binding type field to cache theType{T}value for bindings and directly feed that into ConstType.As a second enhancement, when we don't already have a Type{T} value, we could make the corresponding
ConstTypefield lazily computed on the firstwidenconst. However, because this would requires makingConstTypemutable, this change is a bit of a wash performance wise. I included it in the anticipation that codegen for mutable types with const fields will improve in the future, but it's optional.