-
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
Use a single function for query manipulations #77833
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
I vaguely recall that this may have affected performance (e.g. see careful @bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit fd60635 with merge f8ec1548e1d547c63153b5e662eda2db7306b2f2... |
☀️ Try build successful - checks-actions, checks-azure |
Queued f8ec1548e1d547c63153b5e662eda2db7306b2f2 with parent 63962f0, future comparison URL. |
Finished benchmarking try commit (f8ec1548e1d547c63153b5e662eda2db7306b2f2): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
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.
This refactoring should improve bootstrap times a bit, because it removes 216 000 llvm-lines (-1%).
Before: Lines Copies Function name
-------------- ------ -------------
20218434 (100%) 600060 (100%) (TOTAL)
457651 (2.3%) 414 (0.1%) rustc_query_system::query::plumbing::get_query_impl::{{closure}}
168207 (0.8%) 354 (0.1%) rustc_query_system::query::plumbing::force_query_impl::{{closure}}
95634 (0.5%) 207 (0.0%) rustc_query_system::query::plumbing::incremental_verify_ich
87688 (0.4%) 4335 (0.7%) core::ops::function::FnOnce::call_once
75830 (0.4%) 621 (0.1%) <rustc_query_system::query::caches::DefaultCache<K,V> as rustc_query_system::query::caches::QueryCache>::iter
69233 (0.3%) 207 (0.0%) rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
41047 (0.2%) 207 (0.0%) rustc_query_system::query::plumbing::get_query_impl
After: Lines Copies Function name
------------- ------ -------------
20001669 (100%) 595297 (100%) (TOTAL)
434107 (2.2%) 354 (0.1%) rustc_query_system::query::plumbing::call_query_impl::{{closure}}
85516 (0.4%) 4257 (0.7%) core::ops::function::FnOnce::call_once
81774 (0.4%) 177 (0.0%) rustc_query_system::query::plumbing::incremental_verify_ich
75830 (0.4%) 621 (0.1%) <rustc_query_system::query::caches::DefaultCache<K,V> as rustc_query_system::query::caches::QueryCache>::iter
59176 (0.3%) 177 (0.0%) rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
47042 (0.2%) 177 (0.0%) rustc_query_system::query::plumbing::call_query_impl
(Omitted all entries from other crates; mostly core, alloc and hashbrown.)
key: query_keys::$name<$tcx>, | ||
caller: QueryCaller<DepKind>, | ||
) -> Option<<queries::$name<$tcx> as QueryConfig<TyCtxt<$tcx>>>::Stored> { | ||
call_query::<queries::$name<'_>, _>(tcx, span, key, caller) |
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.
Why is this wrapper needed? Can't the three places where this is used call call_query::<queries::$name<'_>, _>(tcx, span, key, caller)
directly?
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.
The point is to monomorphize call_query
only once for each query. The easiest way is to call it through a monomorphic function.
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.
I just tested removing the wrapper. It removed another 39 022 llvm-lines.
I guess call_query
is only monomorphized once for each query anyway, even though it is called from multiple places.
Edit: Created cjgillot#1
) where | ||
C: QueryCache, | ||
C::Key: Eq + Clone + crate::dep_graph::DepNodeParams<CTX>, | ||
fn ensure_query_impl<CTX, K, V>(tcx: CTX, key: &K, query: &QueryVtable<CTX, K, V>) -> bool |
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.
Can you add a comment what this bool means?
where | ||
C: QueryCache, |
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.
Glad to see this C: QueryCache
clause removed ^^
It is annoying when trying to make things dyn
.
LLVM-lines was the target, but perf is bad. Bootstrap times are not a win either. This definitely needs more work. |
☔ The latest upstream changes (presumably #77871) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
☔ The latest upstream changes (presumably #78334) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Closed in favor of #78780. |
There are three ways to invoke a query: get the value, ensure it runs, or have it automatically forced.
The three corresponding methods are merged into a single point of entry.
The goal is to increase the code sharing between the three cases.