Improve canonicalization performance by introducing TypingMode::ErasedNotCoherence#155443
Improve canonicalization performance by introducing TypingMode::ErasedNotCoherence#155443jdonszelmann wants to merge 9 commits intorust-lang:mainfrom
TypingMode::ErasedNotCoherence#155443Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
|
@bors try parent=14196dbfa3eb7c30195251eac092b1b86c8a2d84 |
This comment has been minimized.
This comment has been minimized.
[DO NOT MERGE] Improve canonicalization performance
|
@rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (db1df07): 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 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 -0.9%, secondary 1.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.4%, secondary 28.5%)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: 491.114s -> 492.029s (0.19%) |
|
changes to the core type system cc @lcnr Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE machinery Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
TypingMode::ErasedNotCoherence
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot)For more information how to resolve CI failures of this job, visit this link. |
|
☔ The latest upstream changes (presumably #155953) made this pull request unmergeable. Please resolve the merge conflicts. |
| // If we get here in erased mode, we don't know the original typing mode. | ||
| // It could be post analysis, or something else. | ||
| // Regardless of what it was, we want to continue in erased mode, | ||
| // if we end up accessing any opaque types we bail out anyway. | ||
| | TypingMode::ErasedNotCoherence(MayBeErased) => return self, |
There was a problem hiding this comment.
not too happy about this, want to get back to this
| self.opaque_accesses | ||
| .rerun_if_in_post_analysis("normalize opaque type non local"); | ||
| } | ||
| if self.opaque_accesses.should_bail() { |
There was a problem hiding this comment.
canfn rerun_if_in_post_analysis just return a Result<(), ShouldBail> or what not so we don't have to manually call should_bail afterwards
| @@ -71,7 +71,13 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< | |||
| // FIXME: Properly consider opaques here. | |||
| && self.inner.borrow_mut().opaque_types().is_empty() | |||
There was a problem hiding this comment.
maybe have a self.known_no_opaque_types_in_storage which returns false if typng mode is erased?
There was a problem hiding this comment.
then we still should return None though right? Cause we can keep the fast path
r? @lcnr
This introduces
TypingMode::ErasedNotCoherence. Most typing modes contain a list of opaque types, which are quite often unused during canonicalization. With this change, any time we try canonicalization, we replace whichever typing mode we're currently in withErasedNotcoherence, attempt to canonicalize, and if that fails retry in the original typing mode. If erased mode succeeds, this is beneficial because that way the opaque types don't end up in the cache key, allowing more cache reuse.This seems to have a small (0.5%) slowdown on most programs, but a dramatic (>60%) speedup in specific cases like the rustc-perf
wg-grammarbenchmark. Some more improvements are expected with "eager normalization", which is work that's under way right now.