Skip to content

Access less HIR attributes from typeck #144841

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 5 commits into
base: master
Choose a base branch
from

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Aug 2, 2025

Typeck relies on attributes to modify its own behaviour. This is a problem, as this means that typeck(some function) may depend on the span and doc-comments of many other functions.

This PR attempts to reduce such accesses to attributes. This yields to a sizeable perf improvement: #144841 (comment)

Fixes #124352

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 2, 2025
@cjgillot
Copy link
Contributor Author

cjgillot commented Aug 2, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 2, 2025
Access less HIR attributes from typeck
@rust-bors
Copy link

rust-bors bot commented Aug 2, 2025

⌛ Trying commit d414182 with merge 23dde9b

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 2, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 2, 2025

💔 Test failed (CI). Failed jobs:

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

cjgillot commented Aug 3, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 3, 2025
Access less HIR attributes from typeck
@rust-bors
Copy link

rust-bors bot commented Aug 3, 2025

⌛ Trying commit bf644e9 with merge 038c022

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

@rust-bors
Copy link

rust-bors bot commented Aug 3, 2025

☀️ Try build successful (CI)
Build commit: 038c022 (038c02289a15c742f6a0d54925c12902ffe09884, parent: f34ba774c78ea32b7c40598b8ad23e75cdac42a6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (038c022): comparison URL.

Overall result: ❌ regressions - no action needed

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.

@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
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 1.5%, secondary 4.3%)

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

mean range count
Regressions ❌
(primary)
1.5% [1.4%, 1.5%] 2
Regressions ❌
(secondary)
4.3% [2.0%, 7.4%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.5% [1.4%, 1.5%] 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: 467.629s -> 467.286s (-0.07%)
Artifact size: 376.97 MiB -> 376.99 MiB (0.00%)

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

cjgillot commented Aug 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 5, 2025

❌ Encountered an error while executing command

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 5, 2025
@cjgillot
Copy link
Contributor Author

cjgillot commented Aug 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 5, 2025
Access less HIR attributes from typeck
@rust-bors
Copy link

rust-bors bot commented Aug 5, 2025

⌛ Trying commit 5073886 with merge 5d925fe

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

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

cjgillot commented Aug 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 5, 2025
Access less HIR attributes from typeck
@rust-bors
Copy link

rust-bors bot commented Aug 5, 2025

⌛ Trying commit 6b7f8fb with merge f6975aa

(The previously running try build was automatically cancelled.)

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

@rust-bors
Copy link

rust-bors bot commented Aug 5, 2025

☀️ Try build successful (CI)
Build commit: f6975aa (f6975aac40d95c9f541dab9405d2581147ad9db7, parent: 0060d5a2a8a86a31f6299311fe64b1d755a91c4f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f6975aa): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.6% [-7.1%, -0.2%] 18
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.1%] 18
All ❌✅ (primary) -1.6% [-7.1%, -0.2%] 18

Max RSS (memory usage)

Results (primary -1.8%, secondary 0.3%)

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.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
-1.8% [-2.7%, -1.2%] 4
Improvements ✅
(secondary)
-1.9% [-1.9%, -1.9%] 1
All ❌✅ (primary) -1.8% [-2.7%, -1.2%] 4

Cycles

Results (primary -5.5%)

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)
-5.5% [-7.1%, -2.7%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -5.5% [-7.1%, -2.7%] 5

Binary size

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

Bootstrap: 466.337s -> 468.162s (0.39%)
Artifact size: 376.97 MiB -> 376.97 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 5, 2025
@cjgillot cjgillot marked this pull request as ready for review August 5, 2025 10:44
@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Aug 5, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@@ -894,7 +896,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}

// If we have `rustc_do_not_const_check`, do not check `[const]` bounds.
if self.tcx.has_attr(self.body_id, sym::rustc_do_not_const_check) {
if self.has_rustc_attrs && self.tcx.has_attr(self.body_id, sym::rustc_do_not_const_check) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not certain that this change is correct. OTOH, do we still need the shortcut when the trait solver and const-checking have this check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

ICE: None in rustc_hir_typeck due to malformed attribute
5 participants