Repository navigation
Rollup of 4 perf-sensitive pull requests - #166613
Conversation
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.
|
@bors r+ p=5 force |
This comment has been minimized.
This comment has been minimized.
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 differencesShow 138 test diffs138 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 063219d04d8b3428506da3d8585c0221c07ca15b --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (063219d): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary -2.5%, secondary -1.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 471.839s -> 461.754s (-2.14%) |
|
📌 Perf builds for each rolled up PR:
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 all |
Running triage with 36 benchmarksTriage only executes the benchmarks on rollup members, that were changed significantly on the rollup.
#165489 1ea7d49 Add two extra early return checks to
|
| 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.
Successful merges:
is_recursive_terminator#165489 (Add two extra early return checks tois_recursive_terminator)r? @ghost
Create a similar rollup