-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Don't opt_rpitit_info
as a separate query
#109057
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 80e963b35d9173ab99b014f5c2e9b3556ba63e68 with merge 84675a5b3bd77db9e6142ec6a6756f3e346332e7... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (84675a5b3bd77db9e6142ec6a6756f3e346332e7): 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)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
I think this helps with most of the regressions in #108700. I can fix that FIXME in a follow-up. r? @spastorino cc @nnethercote |
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.
In general the approach looks good to me.
@@ -244,7 +244,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { | |||
} | |||
|
|||
// Avoid accessing the HIR for the synthesized associated type generated for RPITITs. | |||
if self.tcx.opt_rpitit_info(id).is_some() { | |||
if self.tcx.opt_rpitit_info(id.to_def_id()).is_some() { |
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'm not sure what's makes the opt_rpitit_info
query be fired that much, if it's this call or the other one (because there are just 2), but this call could be the one. I was wondering, what if we make find_by_def_id
called below return None
for rpitits and the code on line 256 would just be ...
self.live_symbols.insert(id);
if let Some(node) = self.tcx.hir().find_by_def_id(id) {
self.visit_node(node);
}
I'm not sure if there's any other situation where find_by_def_id
returns None
and we don't want to do self.live_symbols.insert(id)
, though.
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.
With this patch ...
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index 746cf488589..e76de89e432 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -316,7 +316,7 @@ pub fn find(self, id: HirId) -> Option<Node<'hir>> {
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
#[inline]
pub fn find_by_def_id(self, id: LocalDefId) -> Option<Node<'hir>> {
- self.find(self.local_def_id_to_hir_id(id))
+ self.find(self.tcx.opt_local_def_id_to_hir_id(id)?)
}
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 73ee51d5f3a..1d713bbd055 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -243,18 +243,12 @@ fn mark_live_symbols(&mut self) {
continue;
}
- // Avoid accessing the HIR for the synthesized associated type generated for RPITITs.
- if self.tcx.opt_rpitit_info(id).is_some() {
- self.live_symbols.insert(id);
- continue;
- }
-
// in the case of tuple struct constructors we want to check the item, not the generated
// tuple struct constructor function
let id = self.struct_constructors.get(&id).copied().unwrap_or(id);
+ self.live_symbols.insert(id);
if let Some(node) = self.tcx.hir().find_by_def_id(id) {
- self.live_symbols.insert(id);
self.visit_node(node);
}
}
all the tests pass. May worth running perf on this?.
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.
That change seems orthogonal to this one -- this PR still demonstrates that we don't need opt_rpitit_info
as a query, which is a change I want anyways because storing it in the AssocTy
just seems cleaner.
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.
To be clear, if we keep opt_rpitit_info
around, other PRs may add other calls to the query that may cause regressions. Let's avoid this by fixing the problem at its source. This optimization may also be helpful, feel free to test it if you want, but I'm gonna land this PR I think.
if it's this call or the other one (because there are just 2)
There are 5 calls to opt_rpitit_info
that I can see in the codebase.
@compiler-errors r=me when you decide what to do with the rest of the comments :) but whatever you decide is fine by me. |
80e963b
to
cbd8ea0
Compare
@bors r=spastorino |
📌 Commit cbd8ea01a77d0aefc8eddb89203105f3ee661acf has been approved by It is now in the queue for this repository. |
cbd8ea0
to
ce8dae5
Compare
Few more comments @bors r=spastorino |
☀️ Test successful - checks-actions |
Finished benchmarking commit (0058748): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression 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)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
... another attempt to undo regressions
r? @ghost