Skip to content

Skippable lints: account for lint capping and use in more places - #160126

Open
joshtriplett wants to merge 5 commits into
rust-lang:mainfrom
joshtriplett:skippable-lints
Open

Skippable lints: account for lint capping and use in more places#160126
joshtriplett wants to merge 5 commits into
rust-lang:mainfrom
joshtriplett:skippable-lints

Conversation

@joshtriplett

@joshtriplett joshtriplett commented Jul 29, 2026

Copy link
Copy Markdown
Member

View all comments

skippable_lints allows the compiler to skip doing some work if it only supports a lint that the compiler won't emit. However, skippable_lints didn't take --cap-lints into account. Since dependencies build with --cap-lints allow, it's taking that into account to allow skipping more code when building dependencies.

The rest of this PR adds some additional uses of skippable_lints to skip some potentially expensive operations.


All code in this PR is 100% human-written by me. I used an AI to search for potential performance issues when building an exceptionally large crate (aws-sdk-ec2).

@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added 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 29, 2026
@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 16 candidates

@joshtriplett

Copy link
Copy Markdown
Member 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 Jul 29, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 29, 2026
Skippable lints: account for lint capping and use in more places
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 29, 2026
@rust-bors

rust-bors Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

💥 Test timed out after 21600s

@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2026
@rust-log-analyzer

This comment has been minimized.

Dependencies get built with `--cap-lints allow`, so there's value in
allowing capped lints to be skipped, even if the crate itself doesn't
allow them.
`late_lint_mod` constructs `LateContext` immediately, before figuring
out if the whole pass will be skipped. Move its construction into
`late_lint_mod_inner`, so it doesn't get called if the pass gets
skipped.
These lints will be skippable when building a crate with `--cap-lints
allow`, which occurs for every dependency crate. In such cases, we can
skip the whole query.
`-Zfuture-incompat-test` forces non-allow lints to report as
future-compat. Unfortunately, rather than doing so by modifying the
lints themselves, it requires checking separately. Check it and prevent
skipping lints if enabled.
@rustbot

rustbot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@joshtriplett

Copy link
Copy Markdown
Member Author

I reverted the skip of check_mod_deathness due to the test failures; I think there may be a better fix that would allow that skip, but that can happen in a separate PR.

@joshtriplett

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 31, 2026
Skippable lints: account for lint capping and use in more places
@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 9162c22 (9162c22b7da6084bf42d5c5306e048e574093367)
Base parent: 8ab9fdf (8ab9fdff5a91b9f2b5ed57fb0275452d9a0d0280)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9162c22): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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.2% [0.1%, 0.2%] 2
Regressions ❌
(secondary)
0.2% [0.1%, 0.3%] 6
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-0.8% [-1.2%, -0.2%] 7
All ❌✅ (primary) -0.1% [-0.3%, 0.2%] 4

Max RSS (memory usage)

Results (primary -2.4%, secondary 1.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)
6.4% [6.4%, 6.4%] 1
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-1.3% [-1.9%, -0.7%] 2
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

Results (primary -0.3%, 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.6% [0.5%, 0.7%] 5
Regressions ❌
(secondary)
1.6% [0.6%, 3.2%] 6
Improvements ✅
(primary)
-0.9% [-2.3%, -0.6%] 6
Improvements ✅
(secondary)
-2.0% [-4.5%, -0.5%] 9
All ❌✅ (primary) -0.3% [-2.3%, 0.7%] 11

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 492.09s -> 489.291s (-0.57%)
Artifact size: 390.63 MiB -> 390.56 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 Jul 31, 2026
@joshtriplett

Copy link
Copy Markdown
Member Author

Perf looks somewhere between neutral and win to me.

The bigger win is when building dependencies, which uses --cap-lints allow. (Unfortunately, perf doesn't test that.) This change saved a couple of seconds on a build of a crate with a dependency on aws-sdk-ec2, because that crate has a massive number of items, and this allows skipping some walks on all those items.

Accounting for cap-lints also (for instance) allows crates that explicitly ask for warnings about missing docs to not do the work to produce those warnings when built as a dependency, and various other cases.

@Kobzol

Kobzol commented Jul 31, 2026

Copy link
Copy Markdown
Member

I tried something like this a few times, and my conclusion was that the remaining lints to be skipped are so fast that it's not worth it. But that of course depends on the exact crates that I tested it on.

@lqd

lqd commented Jul 31, 2026

Copy link
Copy Markdown
Member

I've also tried things like this (if you remember, Jakub), and similarly it didn't make much of a difference on many crates then, and only on clean builds of course. We may need to look for outliers on crates.io to see if there are others.

@rust-bors

rust-bors Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

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

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

Labels

perf-regression Performance regression. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants