-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Avoid query type in generics #69910
Avoid query type in generics #69910
Conversation
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
r? @Zoxc |
I'm not sure how many unique key / value pairs we have for queries, if that isn't much lower than the total query count, this change isn't too impactful. |
As a crude measurement, the number of instances of |
That suggests that 26% of query key / value pairs are duplicates, so this is probably worthwhile. |
Why is my |
I was experimenting with it yesterday, and somehow it ended up on the wrong branch. Sorry. |
@bors try @rust-timer queue |
Awaiting bors try build completion |
Avoid query type in generics There are at the moment roughly 170 queries in librustc. The way ty::query is structured, a lot of code is duplicated for each query. I suspect this to be responsible for a part of librustc'c compile time. This PR reduces the amount of code generic on the query, replacing it by code generic on the key-value types. This is split out of #69808, and should not contain the perf regression. cc #65031
☀️ Try build successful - checks-azure |
Queued 4adbc79 with parent 54b7d21, future comparison URL. |
Finished benchmarking try commit 4adbc79, comparison URL. |
src/librustc/ty/query/plumbing.rs
Outdated
pub(super) fn try_collect_active_jobs( | ||
&self, | ||
kind: DepKind, | ||
make_query: impl Fn(C::Key) -> Query<'tcx> + Copy, |
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.
You could use &dyn
for make_query
here.
I measured the compilation impact of the query system to be 25% of librustc's compile time 3. February. |
☔ The latest upstream changes (presumably #68944) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased. |
I'd leave out the |
Done. |
@bors r+ |
📌 Commit 8aa1328 has been approved by |
Avoid query type in generics There are at the moment roughly 170 queries in librustc. The way ty::query is structured, a lot of code is duplicated for each query. I suspect this to be responsible for a part of librustc'c compile time. This PR reduces the amount of code generic on the query, replacing it by code generic on the key-value types. This is split out of rust-lang#69808, and should not contain the perf regression. cc rust-lang#65031
Avoid query type in generics There are at the moment roughly 170 queries in librustc. The way ty::query is structured, a lot of code is duplicated for each query. I suspect this to be responsible for a part of librustc'c compile time. This PR reduces the amount of code generic on the query, replacing it by code generic on the key-value types. This is split out of rust-lang#69808, and should not contain the perf regression. cc rust-lang#65031
Rollup of 6 pull requests Successful merges: - rust-lang#69497 (Don't unwind when hitting the macro expansion recursion limit) - rust-lang#69901 (add #[rustc_layout(debug)]) - rust-lang#69910 (Avoid query type in generics) - rust-lang#69955 (Fix abort-on-eprintln during process shutdown) - rust-lang#70032 (put type params in front of const params in generics_of) - rust-lang#70119 (rustc: use LocalDefId instead of DefId in TypeckTables.) Failed merges: r? @ghost
&self, | ||
state: &'tcx QueryState<'tcx, Q>, | ||
state: &'tcx QueryState<'tcx, Self>, | ||
get_cache: GetCache, |
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.
Now that you connected up the types, you should be able to just get rid of get_cache: GetCache
.
impl<'tcx, C: QueryCache> QueryState<'tcx, C> { | ||
pub(super) fn get_lookup<K2: Hash>( | ||
&'tcx self, | ||
key: &K2, |
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.
K2
can now be C::Key
.
Move the query system to a dedicated crate The query system `rustc::ty::query` is split out into the `rustc_query_system` crate. Some commits are unformatted, to ease rebasing. Based on rust-lang#67761 and rust-lang#69910. r? @Zoxc
There are at the moment roughly 170 queries in librustc.
The way ty::query is structured, a lot of code is duplicated for each query.
I suspect this to be responsible for a part of librustc'c compile time.
This PR reduces the amount of code generic on the query,
replacing it by code generic on the key-value types.
This is split out of #69808,
and should not contain the perf regression.
cc #65031