Optimize unresolved references in semantic #4169
Labels
A-semantic
Area - Semantic
C-performance
Category - Solution not expected to change functional behavior, only performance
#4162 boosted perf of semantic by turning
unresolved_references
into a stack.I think we can potentially do even better. From #4162 (comment):
What I had in mind is that you never call
unresolved_references.pop()
. Instead, hold on to the hash map and re-use it. That way we avoid generating (and allocating) new hash map when entering a scope most of the time.unresolved_references
isVec<UnresolvedReferences>
, indexed by scope depth.e.g. with this input:
UnresolvedReferences
hash map tounresolved_references
.unresolved_references[0]
.foo
:UnresolvedReferences
hash map tounresolved_references
.unresolved_references[1]
.foo
:unresolved_references[1]
).unresolved_references
.unresolved_references[0]
.bar
:unresolved_references
.unresolved_references[1]
(i.e. reuse same hash map that was used forfoo
)bar
: same as forfoo
I think this would be a further perf boost due to reducing allocations, and reusing allocations which are already warm in the cache.
cc @lucab (though no obligation on you to do this)
The text was updated successfully, but these errors were encountered: