Skip to content

Mark span parent in def_collector. #127241

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jul 2, 2024

The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans.

This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive.

r? ghost

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic 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 Jul 2, 2024
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 2, 2024

@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 Jul 2, 2024
@bors
Copy link
Collaborator

bors commented Jul 2, 2024

⌛ Trying commit 95dc7f7 with merge ec84e1c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2024
Mark span parent in def_collector.

The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans.

This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive.

r? ghost
@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot force-pushed the def-collector-span branch from 95dc7f7 to 585fe45 Compare July 2, 2024 15:44
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 2, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 2, 2024

⌛ Trying commit 585fe45 with merge 04122fb...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2024
Mark span parent in def_collector.

The current device of marking spans with a parent def-id during lowering has been frustrating me for quite some time, as it's very easy to forget marking some spans.

This PR moves such marking to the def_collector, which is responsible for creating def-ids on partially expanded AST. This is much more robust as long as visitors are exhaustive.

r? ghost
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 2, 2024

☀️ Try build successful - checks-actions
Build commit: 04122fb (04122fbfda6e59dcf9c54b89353e6d1281c9ebc8)

@rust-timer

This comment has been minimized.

@petrochenkov petrochenkov self-assigned this Jul 2, 2024
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (04122fb): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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)
1.0% [0.2%, 2.5%] 163
Regressions ❌
(secondary)
1.3% [0.3%, 6.2%] 77
Improvements ✅
(primary)
-2.6% [-4.8%, -0.3%] 12
Improvements ✅
(secondary)
-0.5% [-0.7%, -0.4%] 2
All ❌✅ (primary) 0.7% [-4.8%, 2.5%] 175

Max RSS (memory usage)

Results (primary 0.3%, secondary -0.7%)

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.1% [1.4%, 2.6%] 6
Regressions ❌
(secondary)
4.2% [4.0%, 4.6%] 3
Improvements ✅
(primary)
-2.4% [-4.4%, -1.0%] 4
Improvements ✅
(secondary)
-3.6% [-4.3%, -3.2%] 5
All ❌✅ (primary) 0.3% [-4.4%, 2.6%] 10

Cycles

Results (primary 0.6%, secondary 3.2%)

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.0% [0.7%, 3.4%] 28
Regressions ❌
(secondary)
3.2% [2.1%, 4.3%] 11
Improvements ✅
(primary)
-4.9% [-6.0%, -1.4%] 7
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [-6.0%, 3.4%] 35

Binary size

Results (primary -0.2%, secondary -0.2%)

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.1% [0.0%, 0.2%] 7
Regressions ❌
(secondary)
0.1% [0.1%, 0.2%] 6
Improvements ✅
(primary)
-0.2% [-1.7%, -0.0%] 41
Improvements ✅
(secondary)
-0.3% [-0.9%, -0.0%] 13
All ❌✅ (primary) -0.2% [-1.7%, 0.2%] 48

Bootstrap: 695.108s -> 697.834s (0.39%)
Artifact size: 327.55 MiB -> 327.54 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 2, 2024
@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 3, 2024

@petrochenkov do I need to add something to this PR to handle metavar spans, or is this pass enough?

@cjgillot cjgillot force-pushed the def-collector-span branch from 9b82411 to 928d08d Compare July 3, 2024 07:20
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 3, 2024

@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 Jul 3, 2024
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 21, 2025
@bors
Copy link
Collaborator

bors commented Jul 23, 2025

☔ The latest upstream changes (presumably #143897) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot cjgillot force-pushed the def-collector-span branch from c5e1aca to f67fe89 Compare July 26, 2025 00:49
@cjgillot cjgillot marked this pull request as ready for review July 26, 2025 01:14
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 26, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

@cjgillot
Copy link
Contributor Author

I was thinking about the option 1., with an ad-hoc hierarchy. Although I didn't think about the need for stable representation. If SourceItemIds unambiguously map on DefIds later, when DefIds are already assigned, then DefPaths can be reused, I guess? In general, SourceItemIds should be as "temporary" as possible, and we start working in terms of DefIds instead, once they became available.

I'm trying to code that. That's quite a sizeable change, as this requires threading quite some state into the parser. Do you mind considering this PR first, and I'll post a follow-up with this change when I manage coding it?

@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot force-pushed the def-collector-span branch from f67fe89 to d347d18 Compare July 26, 2025 23:54
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jul 26, 2025

⌛ Trying commit d347d18 with merge d091832

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Jul 26, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 26, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 27, 2025

☀️ Try build successful (CI)
Build commit: d091832 (d09183296eff98da36fc9b67356b10cd003747f1, parent: ce5fdd7d42aba9a2925692e11af2bd39cf37798a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d091832): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.8% [0.1%, 11.4%] 136
Regressions ❌
(secondary)
1.1% [0.0%, 11.5%] 83
Improvements ✅
(primary)
-0.5% [-1.0%, -0.2%] 9
Improvements ✅
(secondary)
-0.5% [-1.3%, -0.1%] 19
All ❌✅ (primary) 1.7% [-1.0%, 11.4%] 145

Max RSS (memory usage)

Results (primary 1.9%, secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [0.5%, 7.2%] 23
Regressions ❌
(secondary)
1.5% [0.7%, 2.8%] 4
Improvements ✅
(primary)
-1.0% [-1.6%, -0.4%] 3
Improvements ✅
(secondary)
-1.4% [-1.7%, -1.1%] 2
All ❌✅ (primary) 1.9% [-1.6%, 7.2%] 26

Cycles

Results (primary 7.1%, secondary 5.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
7.6% [2.0%, 16.8%] 37
Regressions ❌
(secondary)
8.1% [2.4%, 16.7%] 8
Improvements ✅
(primary)
-2.3% [-2.5%, -2.1%] 2
Improvements ✅
(secondary)
-2.8% [-2.9%, -2.8%] 2
All ❌✅ (primary) 7.1% [-2.5%, 16.8%] 39

Binary size

Results (primary -0.1%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 4
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 35
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 18
All ❌✅ (primary) -0.1% [-0.2%, -0.0%] 35

Bootstrap: 466.456s -> 465.739s (-0.15%)
Artifact size: 376.58 MiB -> 376.75 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants