Four new-solver speedups - #160605
Conversation
In `from_assoc`, we effectively create a sub-slice of `args`, via interning. But in the case where the sub-slice has the same length as the full slice, we can just reuse the slice. This gives a small perf win.
`impl_is_default` is moderately expensive. This commit moves the cheaper `consider_impl_candidate` check (which does `args_may_unify`) ahead, for a small perf win. (Note: this change makes the new solver match what the old solver does in `assemble_candidates_from_impls`.)
`consider_impl_candidate` calls it once and stores the result in `goal_trait_ref`, and then calls it again shortly after. We can just use `goal_trait_ref` for the second call. This is a moderate perf win.
It's expensive and is called unconditionally in `NormalizesTo::consider_impl_candidate`, which is always called within a loop. The result is invariant across the loop, so this commit hoists the call outside of `consider_impl_candidate` and passes the return value in. Notes: - At the hoist sites, the expression is `goal.predicate.trait_ref(cx)`; for `NormalizesTo` this dispatches to `goal.predicate.alias.trait_ref(cx)`. - Two other `GoalKind` methods are affected, but this doesn't change perf because they can get the `goal_trait_ref` cheaply.
|
@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.
Four new-solver speedups
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (e30e628): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @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 -1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -3.8%, secondary -5.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: 460.81s -> 458.926s (-0.41%) |
|
LLM disclosure: I used an LLM to analyze Cachegrind profiles and identify good optimization opportunities. I wrote all the code and text myself. |

Details in individual commits.