-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use a hash-table when selecting impls #24965
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
The former stopped making sense when we started interning substs and made TraitRef a 2-word copy type, and I'm moving the latter into an arena as they live as long as the type context.
Puts implementations in bins hashed by the fast-reject key, and only looks up the relevant impls, reducing O(n^2)-ishness Before: 688.92user 5.08system 8:56.70elapsed 129%CPU (0avgtext+0avgdata 1208164maxresident)k, LLVM 379.142s After: 637.78user 5.11system 8:17.48elapsed 129%CPU (0avgtext+0avgdata 1201448maxresident)k LLVM 375.552s Performance increase is +7%-ish
I see that you chose to pick the smallest NodeId, which seems fine -- do you feel this resolves your concern here? (It's not clear to me that there is a "wrong" order, but it'd be easiest and best to stick with the same order as the previous code, I agree, and a consistent order is good for testing.) |
OK, so, r+ but I left a few nits and other questions. Nothing egregious, r=me when you've fixed them (or, if there are things you don't agree with, let me know). |
Out of interest, did you end up collecting some? |
@huonw: From the second commit message:
|
This uses a (per-trait) hash-table to separate impls from different TraitDefs, and makes coherence go so much quicker. I will post performance numbers tomorrow. This is still WIP, as when there's an overlap error, impls can get printed in the wrong order, which causes a few issues. Should I pick the local impl with the smallest NodeId to print? Could you take a look at this @nikomatsakis?
This uses a (per-trait) hash-table to separate impls from different TraitDefs, and makes coherence go so much quicker. I will post performance numbers tomorrow.
This is still WIP, as when there's an overlap error, impls can get printed in the wrong order, which causes a few issues. Should I pick the local impl with the smallest NodeId to print?
Could you take a look at this @nikomatsakis?