Repository navigation
Add two extra early return checks to is_recursive_terminator - #165489
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Add two extra early return checks to `is_recursive_terminator`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (9ce971b): 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 @bors rollup=never rustc-perf 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.1%, secondary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.4%, secondary -3.7%)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: 480.462s -> 480.549s (0.02%) |
|
LLM disclosure: this PR is based off LLM analysis. I wrote the code and text myself. |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
Perf results look good: the icount improvements on nalgebra also translate to tangible cycle count and wall-time improvements. |
| // Another check to avoid resolving if we can: this time whether the args can unify. | ||
| // This is the same `relate_rigid_infer` fast reject done by both trait solvers. | ||
| // The `callee != caller` guard means the check is skipped for trait default methods. | ||
| if callee != caller { | ||
| let call_trait_args = | ||
| ty::TraitRef::from_assoc(tcx, tcx.parent(callee), normalized_args).args; | ||
| let impl_trait_args = tcx.impl_trait_ref(tcx.parent(caller)).skip_binder().args; | ||
| if !ty::DeepRejectCtxt::relate_rigid_infer(tcx) | ||
| .args_may_unify(call_trait_args, impl_trait_args) | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
A little annoying that this fast reject is now duplicated. Have you tried benchmarking the two changes individually? Maybe only one of them actually causes most of the perf improvement?
There was a problem hiding this comment.
I tried the trait_item_of one first and that got a smallish win, then I added the args_may_unify and the win slightly more than doubled in size.
There was a problem hiding this comment.
The fast reject duplication is a bit annoying, but I don't see how to avoid it. Normally we fast reject deeper in because we need to enumerate multiple candidates, etc., but here we only need to consider a single candidate.
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.
b903e55 to
6f1344c
Compare
|
This PR changes a file inside |
|
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. |
|
I updated the crash test so it re-manifests, because this PR masked but didn't fix the underlying issue. Note that the cycle count improvements are a bit higher than the instruction count improvements, which is interesting. (Same story with wall-time, though there's more variation there so it's a bit harder to see.) |
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
|
⌛ Testing commit 6f1344c with merge e123531... Workflow: https://github.com/rust-lang/rust/actions/runs/45790303194 |
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #165789. |
|
⌛ Testing commit 6f1344c with merge c1ec7aa... Workflow: https://github.com/rust-lang/rust/actions/runs/45838495794 |
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
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #166588. |
|
@bors rollup=iffy |
…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
…uwer Rollup of 4 perf-sensitive pull requests Successful merges: - #165489 (Add two extra early return checks to `is_recursive_terminator`) - #166248 (Make terminator not optional in BasicBlockData) - #166264 (Perf: Improve looking up previously scanned items in dead-code) - #166492 (rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters)
Rollup merge of #165489 - nnethercote:is_recursive_terminator, 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
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (1ea7d49): comparison URL. Overall result: ✅ improvements - no action needed@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 (secondary -2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.0%, secondary -2.6%)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. Artifact size: 405.62 MiB -> 405.60 MiB (-0.00%) |
…uwer Rollup of 4 perf-sensitive pull requests Successful merges: - rust-lang/rust#165489 (Add two extra early return checks to `is_recursive_terminator`) - rust-lang/rust#166248 (Make terminator not optional in BasicBlockData) - rust-lang/rust#166264 (Perf: Improve looking up previously scanned items in dead-code) - rust-lang/rust#166492 (rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters)

View all comments
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 implsAddfor a matrix type, and+calls on elements also useAdd::add. So more precise checks are needed.r? @oli-obk