-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
performance: Speed up Method Completions By Taking Advantage of Orphan Rules #16555
performance: Speed up Method Completions By Taking Advantage of Orphan Rules #16555
Conversation
26d794d
to
f3d507f
Compare
4e8e251
to
becdc6e
Compare
Right, okay: I addressed the review feedback, except the big one from Waffle. I'm pretty sure I've got a handle on checking fundamental types (I'll pilfer from it from the orphan implementation check), but I'm struggling to get a test with fundamental types working (see the changes in |
Aren't you missing the fundamental check? The fixture seems correct to me |
I am, yeah. I just want to write some tests that invoke fundamental trait impls and then ensure the impl works afterwards (in this PR, to be clear). i’m viewing those tests as a baseline. |
Oh wait, your test fixture is not using the fundamental type in any impl, so how should it show anything? |
Maybe a better of phrasing my question is "do I need to do anything special to introduce a new fundamental type in a fixture, or is the |
Just using the attribute is enough yes, see the orphan check diagnostic fixtures |
becdc6e
to
a8d0dbd
Compare
Alright, I updated the PR to include tests for Notably, I didn't need to make additional changes when filtering to consider fundamental types. |
9ba0c22
to
b5a9609
Compare
b5a9609
to
3cb0f00
Compare
Lgtm with the imports tidied up |
✌️ @davidbarsky, you can now approve this pull request! If @Veykril told you to " |
8613d1b
to
053cdd1
Compare
053cdd1
to
c246a93
Compare
☀️ Test successful - checks-actions |
(Continues #16498)
This PR speeds up method completions by doing two things without regressing
analysis-stats
1:iterate_path_candidates
by relying on orphan rules (see below for a slightly more in-depth explanation). When generating completions onslog::Logger
inoxidecomputer/omicron
as a test, this PR halved my completion times—it's now 454ms cold and 281ms warm. Before this PR, it was 808ms cold and 579ms warm.is_valid_method_candidate
and remove some unnecessary visibility checks. This was suggested by @Veykril in this comment.We filter candidate traits by taking advantage of orphan rules. For additional details, I'll rely on @WaffleLapkin's explanation from Zulip:
Big thanks to Waffle for its keen observation!
I think some additional improvements are possible:
for_trait_and_self_ty
seemingly does not distinguish between&T
,&mut T
, orT
, resulting in seemingly irrelevant traits liketokio::io::AsyncWrite
being being included for, e.g.,&slog::Logger
. I don't know they're being considered due to the autoref/autoderef behavior, but I wonder if it'd make sense to filter by mutability earlier and not consider trait implementations that require&mut T
when we only have a&T
.rustc
. I dunno.Footnotes
The filtering occurs outside of typechecking, after all. ↩