-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Compute lint levels by definition #101620
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 1c1ad06ffc5d637beb672ef9385cfdd3bbe8554d with merge 4ae314edea36bbec3e6a73de890c1d6c727690ac... |
☀️ Try build successful - checks-actions |
Queued 4ae314edea36bbec3e6a73de890c1d6c727690ac with parent 98f3001, future comparison URL. |
Finished benchmarking commit (4ae314edea36bbec3e6a73de890c1d6c727690ac): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
👀 I'm not super familiar with the code, but I can take a shot at reviewing it if you like |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool :) I left a bunch of comments, but not sure whether they're actually bugs or I just don't understand the code.
let LintExpectationId::Unstable { attr_id, lint_index } = unstable_id | ||
else { bug!("stable id Level::from_attr") }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to panic here? I think it should be fine to pass in a stable id, right, we just return Level::Expect(id)
as is?
#[inline(always)] | ||
fn key_as_def_id(&self) -> Option<DefId> { | ||
Some(self.owner.to_def_id()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this is correct? shouldn't we do tcx.hir().local_def_id(self)
instead? ditto for default_span
let is_crate = hir::CRATE_HIR_ID == hir_id; | ||
if is_crate { | ||
levels.add_command_line(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we only adding this for top-level crate? Don't the CLI levels also affect all the other items in the crate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the LintLevelsBuilder
calls lint_levels_on
for all parents.
r? rust-lang/compiler |
Besides the great improvement on the incr-patched cases, there is a ~2 % regression on the incr-unchanged case. I suspect this is due to the query overhead. One possible solution would be to change the granularity of the |
☔ The latest upstream changes (presumably #101736) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after a rebase |
128646a
to
68ec790
Compare
@bors r=oli-obk |
📌 Commit 68ec7901db2efe51948546c2d73ad32dcb06d121 has been approved by It is now in the queue for this repository. |
Finished benchmarking commit (2cb9a65): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
Something went wrong between the previous perf measurement and this one. Filed #101839 to revert. |
Do not fetch HIR node when iterating to find lint. Addresses the regression in rust-lang#101620
Revert perf-regression 101620 Reverts rust-lang#101862 rust-lang#101620 r? `@Mark-Simulacrum`
Revert perf-regression 101620 Reverts rust-lang#101862 rust-lang#101620 r? `@Mark-Simulacrum`
… r=oli-obk Compute lint levels by definition Second attempt to rust-lang#101620. I think that I have removed the perf regression.
Revert perf-regression 101620 Reverts rust-lang#101862 rust-lang#101620 r? `@Mark-Simulacrum`
Lint levels are currently computed once for the whole crate. Any code that wants to emit a lint depends on this single
lint_levels(())
query. This query contains theSpan
for each attribute that participates in the lint level tree, so any code that wants to emit a lint basically depends on the spans in all files in the crate.Contrary to hard errors, we do not clear the incremental session on lints, so this implicit world dependency pessimizes incremental reuse. (And is furthermore invisible for allowed lints.)
This PR completes #99634 (thanks for the initial work @fee1-dead) and includes it in the dependency graph.
The design is based on 2 queries:
lint_levels_on(HirId) -> FxHashMap<LintId, LevelAndSource>
which accesses the attributes at the givenHirId
and processes them into lint levels. TheTyCtxt
is responsible for probing the HIR tree to find the user-visible level.lint_expectations(())
which lists all the#[expect]
attributes in the crate.This PR also introduces the ability to reconstruct a
HirId
from aDepNode
by encoding the local part of theDefPathHash
and theItemLocalId
in the twou64
of the fingerprint. This allows for the dep-graph to directly recomputelint_levels_on
directly, without having to force the calling query.Closes #95094.
Supersedes #99634.