Skip to content

Rollup of 4 perf-sensitive pull requests - #166613

Merged
rust-bors[bot] merged 10 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-Joyx3EL
Nov 26, 2026
Merged

rust-bors[bot] merged 10 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-Joyx3EL

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

nnethercote and others added 10 commits November 11, 2026 10:27
This helps the new solver because resolution is more expensive for it
than the old solver, so it's worth trying harder to avoid it.

The biggest win is for `nalgebra`, because it impls `Add` for a matrix
type, and `+` calls on elements also use `Add::add`. So more precise
checks are needed.

This change avoids the ICE in tests/crashes/152295.rs but doesn't
properly fix the underlying problem, so the commit also modifies that
test to re-expose the ICE.
…ted_parameters

Skip checking functions with fewer than 2 parameters.

Use a stack-allocated SmallVec instead of FxHashMap for small parameters lists

Compare (Symbol, SyntaxContext) directly to avoid calling Ident::normalize_to_macro_rules()
This is dead code now, because terminator is never None. The ice is now triggered sooner in the unwrap in `into_basic_blocks`.
This commit only makes the necessary changes. We don't remove terminator() or terminator_mut() methods to avoid too many changes at once and avoid conflicts.
…r, r=oli-obk

Add two extra early return checks to `is_recursive_terminator`

This helps the new solver because resolution is more expensive for it than the old solver, so it's worth trying harder to avoid it.

The biggest win is for `nalgebra`, because it impls `Add` for a matrix type, and `+` calls on elements also use `Add::add`. So more precise checks are needed.

r? @oli-obk
…r, r=oli-obk

Make terminator not optional in BasicBlockData

This is the final PR for changing `Option<Terminator>` to `Terminator` in `BasicBlockData`. More info in [this thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/vibe.20check.20-.20removing.20Option.20from.20Terminator/with/637588808).

At this point there should never be a case where the terminator is `None`. All usages of `None` were replaced in preceding PR. This PR should practically be a no-op.

First 2 commits remove dead code, the final commit replaces the Option. This PR does try to do only minimal necessary changes to avoid conflicts - i.e. we don't remove `terminator()` and `terminator_mut()` methods or any other cleanups.

This should be reviewable commit by commit. For some changes that are just removing ifs, it's useful to hide whitespace changes.
Perf: Improve looking up previously scanned items in dead-code

Improve `dead-code` performance in looking up whether an item has already been scanned.

Before, we'd keep track of `ScannedItem` which is a combination of `id`, allow/expect and trivial usage site.

The idea here is to replace this, so that the `scanned` map stores the most important context from which we have scanned an item.
Without trivial usage sites, the scanned state of an item would form a total order, i.e. `not scanned at all < scanned from allow expect < scanned normally`. Essentially, the logic determining whether an item should be scanned can be reduced to the question of whether the seed we are coming from is "stronger" than the one from which we have previously scanned this item. This is nice because it means we can change the current set of `ScannedItems` to just a single map with one entry per `DefId` to store the most important context from which an item was scanned and be done, i.e.
`LocalDefIdMap<ScannedFromSeed>` where
```rust
enum ScannedFromSeed {
    Unscanned,
    AllowExpect,
    Live,
}
```

However, with trivial usage sites, there are many new possible scan states that a single item can have, since we need to additionally track the `ScannedFromSeed` for each usage site. Therefore, this PR effectively separates the `scanned` state into two maps:
```rust
scanned: LocalDefIdMap<ScannedFromSeed>,
// the keys are effectively (trivial_usage_site_id, node id)
scanned_trivial: FxHashMap<(LocalDefId, LocalDefId), ScannedFromSeed>,
```

Then, when we scan an item from a trivial usage site, use `scanned_trivial`, otherwise  we use `scanned`.

In my benchmarks, this already helped with performance.As another optimization, using a `IndexVec<LocalDefId, ScannedFromSeed>` instead of a `LocalDefIdMap` made it quite a bit faster (-0.1% on `libc`) in my local perf runs . `dead-code` checks a lot of the `DefId`s in the crate, so a large portion of that vec ends up being full. Out of curiosity, I checked the fill rate of the vec and it varied a lot depending on the benchmark (`unused-warnings` has 100%, `issue-58319` has only 1%), but for real world crates it seemed to be between 20% (`rustc_borrowck`) and 90% (`libc`) (very roughly). The only reason for a definition not to need an entry is if it is either unused or of a kind that we don't check, like generics, closures, ...
…r=panstromek,JonathanBrouwer

rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters

Fixes rust-lang#166410
Slowdown came from the lint in rust-lang#165366 and showed up on `externs` and `libc`

Skip checking functions with fewer than 2 parameters.
Use a stack-allocated `SmallVec` instead of `FxHashMap` for small parameters lists.

Compare `(Symbol, SyntaxContext)` directly to avoid calling `Ident::normalize_to_macro_rules()`

The warnings are unchanged, I ran tests/ui/lint/duplicate-parameter-names.rs,
but looks like we need to do perf again: time regression on `externs` and `libc` should be less.
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Nov 26, 2026
@rustbot rustbot added 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. labels Nov 26, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r+ p=5 force

@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6174e2e has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 26, 2026
@JonathanBrouwer JonathanBrouwer changed the title Rollup of 4 pull requests Rollup of 4 perf-sensitive pull requests Nov 26, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 26, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 26, 2026
@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: JonathanBrouwer
Duration: 2h 57m 4s
Pushing 063219d to main...

@rust-bors
rust-bors Bot merged commit 063219d into rust-lang:main Nov 26, 2026
15 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b3d5b3f (parent) -> 063219d (this PR)

Test differences

Show 138 test diffs

138 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 063219d04d8b3428506da3d8585c0221c07ca15b --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. test-x86_64-gnu-gcc-core-tests: 7m 44s -> 14m 46s (+90.9%)
  2. dist-sparcv9-solaris: 1h 5m -> 1h 41m (+56.6%)
  3. dist-x86_64-msvc-alt: 1h 45m -> 2h 40m (+52.1%)
  4. dist-x86_64-solaris: 1h 8m -> 1h 42m (+48.2%)
  5. test-x86_64-gnu-parallel-frontend: 1h 26m -> 2h 3m (+42.6%)
  6. test-x86_64-gnu-llvm-22: 41m 48s -> 58m 32s (+40.0%)
  7. test-i686-msvc: 3h 18m -> 1h 59m (-39.7%)
  8. test-x86_64-gnu-stdlib-semver-check: 10m 26s -> 14m 26s (+38.3%)
  9. test-x86_64-gnu-stable: 1h 59m -> 2h 45m (+38.2%)
  10. test-x86_64-msvc-ext1: 2h 22m -> 1h 28m (-38.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (063219d): comparison URL.

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

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.3% [0.2%, 0.5%] 4
Improvements ✅
(primary)
-0.4% [-1.4%, -0.2%] 97
Improvements ✅
(secondary)
-0.5% [-2.9%, -0.1%] 69
All ❌✅ (primary) -0.4% [-1.4%, -0.2%] 97

Max RSS (memory usage)

Results (primary 2.8%, 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.8% [1.5%, 4.0%] 2
Regressions ❌
(secondary)
1.0% [0.5%, 1.8%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.9% [-5.1%, -0.5%] 4
All ❌✅ (primary) 2.8% [1.5%, 4.0%] 2

Cycles

Results (primary -2.5%, secondary -1.8%)

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.2%, 3.0%] 2
Improvements ✅
(primary)
-2.5% [-3.4%, -1.9%] 8
Improvements ✅
(secondary)
-2.9% [-6.0%, -1.0%] 8
All ❌✅ (primary) -2.5% [-3.4%, -1.9%] 8

Binary size

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

Bootstrap: 471.839s -> 461.754s (-2.14%)
Artifact size: 405.62 MiB -> 405.59 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 26, 2026
@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#165489 Add two extra early return checks to `is_recursive_terminat… 1ea7d49557034de5d1505bb702920853aaf4b596
(link)
#166248 Make terminator not optional in BasicBlockData 4efae3c08cb52bebb8f956df8dfc63e59cebf2a8
(link)
#166264 Perf: Improve looking up previously scanned items in dead-c… 0ba1f5b38796b59ff0bac4d315604b7167e62cf2
(link)
#166492 rustc-lint: avoid allocation and Ident reconstruction in fi… a00ff46db796fdc47f143850b9ce8b25ef0b8146
(link)

parent commit: b3d5b3ffa1

In the case of a perf regression, run the following command with the SHAs of each PR you suspect might be the cause: @rust-timer triage $SHA $SHA $SHA..., or run @rust-timer triage all to benchmark all rollup members.

@panstromek

Copy link
Copy Markdown
Contributor

@rust-timer triage all

@rust-timer

rust-timer commented Nov 26, 2026 •

Copy link
Copy Markdown
Running triage with 36 benchmarks

Triage only executes the benchmarks on rollup members, that were changed significantly on the rollup.
For this rollup, these benchmarks are:

  • await-call-tree
  • bitmaps-3.2.1
  • bitmaps-3.2.1-new-solver
  • cargo-0.87.1
  • clap_derive-4.5.32
  • clap_derive-4.5.32-nll
  • deeply-nested-multi
  • diesel-2.2.10
  • diesel-2.2.10-new-solver
  • enum-stress
  • externs
  • eza-0.21.2
  • html5ever-0.31.0
  • html5ever-0.31.0-new-solver
  • hyper-1.6.0
  • image-0.25.6
  • include-blob
  • large-workspace
  • libc-0.2.172
  • many-assoc-items
  • nalgebra-0.33.0
  • nalgebra-0.33.0-new-solver
  • regex-automata-0.4.8
  • regression-31157
  • ripgrep-14.1.1
  • ripgrep-14.1.1-nll
  • serde-1.0.219
  • serde-1.0.219-new-solver
  • serde-1.0.219-nll
  • stm32f4-0.15.1
  • syn-2.0.101
  • syn-2.0.101-new-solver
  • tokio-1.53.1
  • typenum-1.18.0
  • typenum-1.18.0-new-solver
  • unused-warnings

#165489 1ea7d49 Add two extra early return checks to is_recursive_terminator

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)
-0.5% [-1.4%, -0.2%] 22
Improvements ✅
(secondary)
-0.8% [-2.8%, -0.1%] 18
All ❌✅ (primary) -0.5% [-1.4%, -0.2%] 22

Max RSS (memory usage)

Results (secondary -2.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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% [-4.9%, -1.0%] 3
All ❌✅ (primary) - - 0

Cycles

Results (primary -1.0%, secondary -2.6%)

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

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.8%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.4%, -1.7%] 7
Improvements ✅
(secondary)
-2.6% [-2.8%, -2.3%] 2
All ❌✅ (primary) -1.0% [-2.4%, 2.8%] 9

Binary size

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


#166248 4efae3c Make terminator not optional in BasicBlockData

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)
-0.3% [-0.4%, -0.1%] 14
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.0%] 22
All ❌✅ (primary) -0.3% [-0.4%, -0.1%] 14

Max RSS (memory usage)

Results (secondary 1.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)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary -1.8%, secondary -2.2%)

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

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.8%, -1.2%] 8
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) -1.8% [-2.8%, 2.0%] 9

Binary size

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


#166264 0ba1f5b Perf: Improve looking up previously scanned items in dead-code

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)
-0.2% [-0.3%, -0.1%] 19
Improvements ✅
(secondary)
-0.5% [-0.7%, -0.2%] 11
All ❌✅ (primary) -0.2% [-0.3%, -0.1%] 19

Max RSS (memory usage)

Results (primary -1.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)
- - 0
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.6% [-1.6%, -1.6%] 1

Cycles

Results (primary -2.4%, secondary -3.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
Improvements ✅
(primary)
-2.4% [-3.1%, -1.7%] 9
Improvements ✅
(secondary)
-3.0% [-3.9%, -2.5%] 3
All ❌✅ (primary) -2.4% [-3.1%, -1.7%] 9

Binary size

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


#166492 a00ff46 rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters

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)
-0.2% [-0.2%, -0.2%] 2
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 3
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 2

Max RSS (memory usage)

Results (primary -2.1%)

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

Cycles

Results (primary -2.4%, secondary -2.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)
- - 0
Improvements ✅
(primary)
-2.4% [-2.9%, -1.7%] 8
Improvements ✅
(secondary)
-2.3% [-2.3%, -2.3%] 1
All ❌✅ (primary) -2.4% [-2.9%, -1.7%] 8

Binary size

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

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

Labels

merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. rollup A PR which is a rollup T-clippy Relevant to the Clippy team. 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