Skip to content

Conversation

@JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Dec 23, 2025

This PR converts cfg and cfg_trace attributes to the new parsed representation.

The primary challenge is that re-parsing these attributes in the HIR is a performance regression, since these attributes were only used in rustdoc and clippy parsing them in the HIR is extra work that was not done in the compiler before. To solve this, we only parse the attributes once and then store their parsed representation in the AST.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 23, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 23, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 23, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Dec 23, 2025

☀️ Try build successful (CI)
Build commit: ed1fb29 (ed1fb2931c0b2ef01da69d775ed80af9ece506fe, parent: 0bd13c38df9a9a922bd8ec98ba7a8bc7e111860e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ed1fb29): 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)
0.3% [0.2%, 0.7%] 6
Regressions ❌
(secondary)
0.3% [0.1%, 0.8%] 5
Improvements ✅
(primary)
-0.3% [-0.5%, -0.1%] 15
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 15
All ❌✅ (primary) -0.1% [-0.5%, 0.7%] 21

Max RSS (memory usage)

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

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

mean range count
Regressions ❌
(primary)
0.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
1.3% [1.2%, 1.3%] 2
Improvements ✅
(primary)
-1.4% [-2.4%, -0.9%] 3
Improvements ✅
(secondary)
-1.0% [-1.2%, -0.8%] 3
All ❌✅ (primary) -0.9% [-2.4%, 0.8%] 4

Cycles

Results (primary 2.8%, secondary 10.9%)

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

mean range count
Regressions ❌
(primary)
2.8% [2.3%, 3.3%] 2
Regressions ❌
(secondary)
10.9% [2.1%, 26.6%] 19
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [2.3%, 3.3%] 2

Binary size

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

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
Improvements ✅
(primary)
-0.4% [-1.9%, -0.0%] 78
Improvements ✅
(secondary)
-0.2% [-0.9%, -0.0%] 16
All ❌✅ (primary) -0.4% [-1.9%, -0.0%] 78

Bootstrap: 481.073s -> 480.532s (-0.11%)
Artifact size: 390.31 MiB -> 390.37 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 23, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 24, 2025
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 24, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Dec 24, 2025

☀️ Try build successful (CI)
Build commit: ffa4b1c (ffa4b1ccb2fcb0f68df82b45ec17492d21980eaa, parent: c4aa646f15e40bd3e64ddb5017b7b89b3646ac99)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ffa4b1c): 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)
0.3% [0.1%, 0.7%] 8
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 3
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 16
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.1%] 11
All ❌✅ (primary) -0.1% [-0.4%, 0.7%] 24

Max RSS (memory usage)

Results (primary -1.0%, 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)
- - 0
Regressions ❌
(secondary)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 3
Improvements ✅
(secondary)
-0.8% [-1.1%, -0.5%] 2
All ❌✅ (primary) -1.0% [-1.1%, -0.9%] 3

Cycles

Results (secondary 2.7%)

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)
2.7% [2.0%, 3.4%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

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
Improvements ✅
(primary)
-0.3% [-1.8%, -0.0%] 94
Improvements ✅
(secondary)
-0.2% [-0.9%, -0.0%] 32
All ❌✅ (primary) -0.3% [-1.8%, -0.0%] 94

Bootstrap: 483.398s -> 483.821s (0.09%)
Artifact size: 392.47 MiB -> 392.44 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 24, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Dec 25, 2025
@JonathanBrouwer
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

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

rust-bors bot commented Dec 26, 2025

☀️ Try build successful (CI)
Build commit: ed96494 (ed9649499f26613701cf867f0c5e196df9329855, parent: fabece9e9491d0a3c3655dba488881968b7c5f7a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ed96494): 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)
0.3% [0.2%, 0.7%] 6
Regressions ❌
(secondary)
0.2% [0.2%, 0.3%] 2
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 15
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.1%] 14
All ❌✅ (primary) -0.1% [-0.4%, 0.7%] 21

Max RSS (memory usage)

Results (primary -1.3%, secondary 1.4%)

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)
3.8% [3.8%, 3.8%] 1
Improvements ✅
(primary)
-1.3% [-2.0%, -0.9%] 3
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) -1.3% [-2.0%, -0.9%] 3

Cycles

Results (secondary -3.4%)

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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.4% [-4.1%, -2.1%] 3
All ❌✅ (primary) - - 0

Binary size

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

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
Improvements ✅
(primary)
-0.5% [-1.8%, -0.0%] 48
Improvements ✅
(secondary)
-0.2% [-0.8%, -0.0%] 14
All ❌✅ (primary) -0.5% [-1.8%, -0.0%] 48

Bootstrap: 482.281s -> 485.842s (0.74%)
Artifact size: 392.44 MiB -> 392.50 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 26, 2025
@JonathanBrouwer JonathanBrouwer changed the title Cfg trace attributes, attempt 2 Port #[cfg] and #[cfg_attr] trace attributes to the new attribute parsers Dec 26, 2025
@JonathanBrouwer
Copy link
Contributor Author

r? @jdonszelmann
The performance is not perfect, but is clearly net positive.
Performance for rustdoc is very positive, performance for rustc is mildly positive.
The negative performance for incremental can be explained by #150400, which should be addressed by #143882

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review December 26, 2025 20:05
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 26, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs

cc @ZuseZ4

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 26, 2025
@GuillaumeGomez
Copy link
Member

Apart from my nit, changes look good, nice work! As discussed on zulip, if you're confident enough with only my review, then r=me, otherwise we can wait for @jdonszelmann to be back. :)

@jdonszelmann
Copy link
Contributor

I'll try to do a review in the next day or two. If this is blocking a lot, then I apologize and feel free to merge

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Dec 27, 2025

This is not blocking, we can wait for Jana, no hurry :)

@GuillaumeGomez
Copy link
Member

I'll try to do a review in the next day or two. If this is blocking a lot, then I apologize and feel free to merge

No need to apologize, merge can wait for you. Enjoy you holidays. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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