Skip to content
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

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

compiler-errors
Copy link
Member

... another attempt to undo regressions

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 12, 2023
@compiler-errors
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 12, 2023
@bors
Copy link
Contributor

bors commented Mar 12, 2023

⌛ Trying commit 80e963b35d9173ab99b014f5c2e9b3556ba63e68 with merge 84675a5b3bd77db9e6142ec6a6756f3e346332e7...

@bors
Copy link
Contributor

bors commented Mar 12, 2023

☀️ Try build successful - checks-actions
Build commit: 84675a5b3bd77db9e6142ec6a6756f3e346332e7 (84675a5b3bd77db9e6142ec6a6756f3e346332e7)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (84675a5b3bd77db9e6142ec6a6756f3e346332e7): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-1.1%, -0.3%] 79
Improvements ✅
(secondary)
-1.2% [-2.8%, -0.2%] 40
All ❌✅ (primary) -0.6% [-1.1%, -0.3%] 79

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
2.4% [1.8%, 3.0%] 2
Regressions ❌
(secondary)
2.7% [2.0%, 3.4%] 2
Improvements ✅
(primary)
-2.1% [-3.0%, -0.8%] 7
Improvements ✅
(secondary)
-3.9% [-8.9%, -0.9%] 6
All ❌✅ (primary) -1.1% [-3.0%, 3.0%] 9

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.8%, -1.1%] 7
Improvements ✅
(secondary)
-3.9% [-5.3%, -2.0%] 12
All ❌✅ (primary) -2.1% [-2.8%, -1.1%] 7

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 13, 2023
@compiler-errors compiler-errors marked this pull request as ready for review March 13, 2023 05:02
@compiler-errors
Copy link
Member Author

I think this helps with most of the regressions in #108700. I can fix that FIXME in a follow-up.

r? @spastorino cc @nnethercote

Copy link
Member

@spastorino spastorino left a 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.

compiler/rustc_metadata/src/rmeta/decoder.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/assoc.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/mod.rs Show resolved Hide resolved
@@ -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() {
Copy link
Member

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.

Copy link
Member

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?.

Copy link
Member Author

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.

Copy link
Member Author

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.

@spastorino
Copy link
Member

@compiler-errors r=me when you decide what to do with the rest of the comments :) but whatever you decide is fine by me.

@compiler-errors
Copy link
Member Author

@bors r=spastorino

@bors
Copy link
Contributor

bors commented Mar 13, 2023

📌 Commit cbd8ea01a77d0aefc8eddb89203105f3ee661acf has been approved by spastorino

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 13, 2023
@compiler-errors
Copy link
Member Author

Few more comments

@bors r=spastorino

@bors
Copy link
Contributor

bors commented Mar 13, 2023

📌 Commit ce8dae5 has been approved by spastorino

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Mar 14, 2023

⌛ Testing commit ce8dae5 with merge 0058748...

@bors
Copy link
Contributor

bors commented Mar 14, 2023

☀️ Test successful - checks-actions
Approved by: spastorino
Pushing 0058748 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 14, 2023
@bors bors merged commit 0058748 into rust-lang:master Mar 14, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0058748): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-1.1%, -0.2%] 86
Improvements ✅
(secondary)
-1.2% [-2.7%, -0.2%] 38
All ❌✅ (primary) -0.5% [-1.1%, -0.2%] 86

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
1.9% [1.3%, 2.5%] 2
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
-1.9% [-3.1%, -0.6%] 10
Improvements ✅
(secondary)
-2.4% [-5.9%, -1.3%] 11
All ❌✅ (primary) -1.3% [-3.1%, 2.5%] 12

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.2%, 2.7%] 3
Improvements ✅
(primary)
-2.2% [-2.9%, -0.9%] 9
Improvements ✅
(secondary)
-3.5% [-4.8%, -2.1%] 12
All ❌✅ (primary) -2.2% [-2.9%, -0.9%] 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants