-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[perf] separate impls for refs to simplifiable types #106155
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 89df198d30df99b9bc5c6738380f0b7b3759a1af with merge 8185d21406dfb1106547fc5cb973f6dffdc2b574... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (8185d21406dfb1106547fc5cb973f6dffdc2b574): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. |
I'm not sure this is complete just yet or if it's still missing some important changes, so I'll leave it as draft for now, and I'd also like to add some tests. But since this topic showed up in the discussion to reduce hotspots for the atypical
As shown in the perf run above, these patterns are quite uncommon in our benchmark suite, and I believe in the wider ecosystem, but they do stress coherence, and could be present in other similar big crates bindings to existing type hierarchies (e.g. to other OS APIs, maybe UI toolkits with OOP flavors, etc). With that in mind, r? @lcnr for when they come back from vacation. |
if let Some(impls) = impls.impls_for_ref_x.get(&simplified_ref_ty) { | ||
return impls.iter().copied(); | ||
} | ||
} |
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.
missing the impls_for_ref_x
impls if you have &T
. Doesn't matter with how this method is used but we should still be careful for it to be correct.
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.
a few nits, after that
r=me
ah for tests: probably:
coherence: impls with That should cover all the edge cases I can think of rn |
This comment was marked as outdated.
This comment was marked as outdated.
Separate impls for references to simplifiable types to allow for faster lookups: the set of possibly matching impls is smaller than if we stored them all as `SimplifiedType::RefSimplifiedType`.
handle `impls_for_ref_x` and reduce duplication when iterating over all impls. also: use it in `for_each_relevant_impl_treating_projections`
for users of the API, we return impls from `non_blanket_impls` and `impls_for_ref_x` as if they weren't separated.
(rebased to discuss with lcnr, but the PR is still waiting on me) @bors try |
⌛ Trying commit 030f9bb with merge cd2704ff205c1cca87105183ec3fc80182b8f5bb... |
☀️ Try build successful - checks-actions |
Sanity check on
|
Coherence checks are on their way of being switched from the current solver to the next trait solver, via However, this PR while being very beneficial to e.g. |
As discussed on zulip, some of the coherence checks on the
window
crates are hot onRefSimplifiedType
s, I believe because the crate contains a lot of types withFrom
conversions between them (emulatingCOM
hierarchies IIUC), including references to these types.This PR separates impls for references to simplifiable types from the current non-blanket impls, for faster lookups.
Opening as draft for feedback purposes, especially as to what kind of tests @lcnr would like to see in this PR.