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

rustc: Make def_kind mandatory for all DefIds #118250

Merged
merged 1 commit into from
Nov 26, 2023

Conversation

petrochenkov
Copy link
Contributor

Prerequisite for #118188.

@rustbot
Copy link
Collaborator

rustbot commented Nov 24, 2023

r? @TaKO8Ki

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Nov 24, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 24, 2023

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@petrochenkov
Copy link
Contributor 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 Nov 24, 2023
@bors
Copy link
Contributor

bors commented Nov 24, 2023

⌛ Trying commit 331df84 with merge f86037d...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 24, 2023
rustc: Make `def_kind` mandatory for all `DefId`s

Prerequisite for rust-lang#118188.
@bors
Copy link
Contributor

bors commented Nov 24, 2023

☀️ Try build successful - checks-actions
Build commit: f86037d (f86037df69d1452502b1846b6754a21a1e184d23)

@rust-timer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 like this a lot. a few comments (and i know perf is running)

compiler/rustc_metadata/src/rmeta/mod.rs Outdated Show resolved Hide resolved
@@ -895,7 +891,7 @@ impl<'hir> Map<'hir> {

#[inline]
fn opt_ident(self, id: HirId) -> Option<Ident> {
match self.get(id) {
match self.find(id)? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What codepath triggers this specifically? Just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def_span for anonymous constants without HIR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep a FIXME here too?

Copy link
Contributor Author

@petrochenkov petrochenkov Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HirIds do not always have HIR nodes or Idents, so the new behavior looks reasonable to me, we just didn't hit this case before.

compiler/rustc_metadata/src/rmeta/encoder.rs Show resolved Hide resolved
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f86037d): 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.2% [-0.2%, -0.1%] 4
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.2%] 9
All ❌✅ (primary) -0.2% [-0.2%, -0.1%] 4

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)
3.2% [3.2%, 3.2%] 1
Regressions ❌
(secondary)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
-0.9% [-0.9%, -0.9%] 1
All ❌✅ (primary) -0.1% [-3.4%, 3.2%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 674.644s -> 675.592s (0.14%)
Artifact size: 313.53 MiB -> 313.54 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 25, 2023
@@ -1393,7 +1392,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
if should_encode_fn_sig(def_kind) {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
}
if should_encode_generics(def_kind) {
// FIXME: Some anonymous constants produced by `#[rustc_legacy_const_generics]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we give them a dummy hir node to avoid those ices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I just didn't want to get into that in this PR, #118188 is not blocked on it.

I tried to look what exactly happens with rustc_legacy_const_generics, but it's still not clear to me.
There seems to be some mismatch between what def collector and AST lowering do.

@@ -895,7 +891,7 @@ impl<'hir> Map<'hir> {

#[inline]
fn opt_ident(self, id: HirId) -> Option<Ident> {
match self.get(id) {
match self.find(id)? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep a FIXME here too?

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me unless you want another round of review from cjgillot

@petrochenkov
Copy link
Contributor Author

@bors r=compiler-errors
I'd want to see #118250 (comment) addressed somehow, just don't have time to investigate right now.

@bors
Copy link
Contributor

bors commented Nov 25, 2023

📌 Commit 2c23386 has been approved by compiler-errors

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 Nov 25, 2023
@bors
Copy link
Contributor

bors commented Nov 26, 2023

⌛ Testing commit 2c23386 with merge 5c97719...

@bors
Copy link
Contributor

bors commented Nov 26, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 5c97719 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 26, 2023
@bors bors merged commit 5c97719 into rust-lang:master Nov 26, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 26, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5c97719): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.5% [0.5%, 0.5%] 2
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 5
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.2%] 9
All ❌✅ (primary) -0.1% [-0.1%, -0.1%] 5

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)
- - 0
Regressions ❌
(secondary)
3.7% [2.8%, 4.5%] 2
Improvements ✅
(primary)
-2.0% [-2.4%, -1.6%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-2.4%, -1.6%] 2

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 674.797s -> 672.47s (-0.34%)
Artifact size: 313.34 MiB -> 313.36 MiB (0.01%)

@nnethercote
Copy link
Contributor

If anything, this looks like a tiny performance win.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 26, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 28, 2023
resolve: Feed the `def_kind` query immediately on `DefId` creation

Before this PR the def kind query required building HIR for no good reason, with this PR def kinds are instead assigned immediately when `DefId`s are created.

Some PRs previously refactored things to make all def kinds to be available early enough - rust-lang#118250, rust-lang#118272, rust-lang#118311.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2023
…errors

rustc: Make `def_kind` mandatory for all `DefId`s

Prerequisite for rust-lang#118188.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

8 participants