-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix quadratic performance with lots of use statements #43584
Conversation
We already had a cache for file contents, but we read the source-file before testing the cache, causing obvious slowness, so this just avoids loading the source-file when the cache already has the contents.
Instead of finding the next free disambiguator by incrementing it until you find a place, store the next available disambiguator in an hash-map. This avoids O(n^2) performance when lots of items have the same un-disambiguated `DefPathData` - e.g. all `use` items have `DefPathData::Misc`.
if *self.external_src.borrow() == ExternalSource::AbsentOk { | ||
let src = get_src(); |
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.
Oh wow, my bad, I didn't notice that it was loading the file each time in the original PR.
@bors r+ |
📌 Commit 70478ca has been approved by |
Thanks for the quick fix @arielb1! |
Could this be uplifted to beta @arielb1 ? Firefox would love having this in the 1.20 release! |
I agree with backporting to beta. cc @nikomatsakis |
☀️ Test successful - status-appveyor, status-travis |
Tagging as accepted for beta |
This fixes 2 problems that caused quadratic performance when lots of use-statements were present. After this patch, performance is linear (and very fast) even with 1M uses.
Fixes #43572.
Fixes #43573.
r? @eddyb