-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Removes TraitMap::insert_for_type. #6867
base: master
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #6867 will not alter performanceComparing Summary
|
61fed08
to
ee4d114
Compare
ee4d114
to
057d1ea
Compare
057d1ea
to
c3db20f
Compare
c3db20f
to
f17481b
Compare
Some use cases require the compiler to call insert_implementation_for_type on every call of find_method_for_type. This would double the compile time of a simple script. To avoid this we removed the TraitMap::insert_for_type. The TraitMap now only stores the original implementations and uses a less restrictive unify_check to get those that match the concrete implementations. This reduces significantly the size of the TraitMap and speeds up the lookup times. On the other hand, it also introduces a type substitution on every find_method_for_type. A future PR will address the performance of doing type substitutions.
f17481b
to
0b6370a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% I understand what's going on, but it looks ok.
The two comments I've made are mostly something that looks odd - I don't know if they're actual mistakes. Maybe it would be worth adding comments in those places to avoid future confusion.
} | ||
if engines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be an else if
? There's a risk you'll perform two insertions AFAICT.
.collect::<Vec<_>>(); | ||
if !matches.is_empty() { | ||
type_id_type_subst_map | ||
.insert(impl_type_parameter.type_id, matches[0].0.type_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised you only need to look at matches[0]
and not the rest of the matches.
e55642d
to
447a6e9
Compare
Description
Some use cases require the compiler to call insert_implementation_for_type on every call of find_method_for_type.
This would double the compile time of a simple script. To avoid this we removed the TraitMap::insert_for_type. The TraitMap now only stores the original implementations and uses a less restrictive unify_check to get those that match the concrete implementations.
This significantly reduces the TraitMap's size and speeds up the lookup times. On the other hand, it also introduces a type substitution on every find_method_for_type.
A future PR will address the performance of doing type substitutions.
Fixes #5002.
Fixes #6858
Checklist
Breaking*
orNew Feature
labels where relevant.