speed up next-solver on some pathological cases - #161274
Conversation
|
changes to the core type system cc @lcnr |
This comment has been minimized.
This comment has been minimized.
This comment was marked as outdated.
This comment was marked as outdated.
| @@ -5,6 +5,7 @@ | |||
|
|
|||
| use std::iter; | |||
|
|
|||
| use rustc_data_structures::fx::FxHashSet; | |||
There was a problem hiding this comment.
something something comparing this to DelayedSet 🤔
I would expect WF to mostly be for quite small types
There was a problem hiding this comment.
these UI tests you've added do compile even without this fix, don't they? They are just really slow. I am worried about using UI tests here as it's hard to deal with them again. I would instead prefer adding these as secondary benchmarks, cc @rust-lang/wg-compiler-performance
| ) -> Result<Option<I::Const>, RerunNonErased> { | ||
| if self.typing_mode().is_erased_not_coherence() { | ||
| match self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)? {} | ||
| let resolved = self.resolve_vars_if_possible(alias_const); |
There was a problem hiding this comment.
@jdonszelmann mind taking this over?
We originally bailed here because we didnt want to deal with the exact behavior of evaluate_const and how it accesses the TypingMode/opaque type storage. also cc https://rust-lang.zulipchat.com/#narrow/channel/260443-project-const-generics/topic/.60evaluate_const.60.20is.20scary/near/617438696 @BoxyUwU @zedddie as we're changing evaluate const to a next-solver only method at which point handling ErasedNonCoherence correctly becomes even easier 🤔
would you mind moving this change out of this PR as the other one feels a lot easier to merge :>
|
Let's check whether this is visible on our current benchmarks. If not, then yes, it'd be nice to add new secondary one for this. @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.
speed up next-solver on some pathological cases
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (71c2d57): 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 0.7%, secondary -2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 456.256s -> 457.184s (0.20%) |
|
If we do add a secondary benchmark we should do it with intention. We probably have multiple pathological cases for the new trait solver. It would be good to gather them into a single benchmark rather than adding, say, five new tiny benchmarks. The ctfe-stress benchmark is an example where this has been done in the past. |
|
Ooh, interesting perf. For now, I got rid of the 2 uitests and the second commit, and replaced the FxHashSet with a DelayedSet. The const eval PR is here: #161380 |
Part of speeding up compiling
ReShellwith-Znext-solver, see rust-lang/trait-system-refactor-initiative#272 and #t-types/trait-system-refactor > more `reshell` slowness.The PR changes the
WfPredicatesvisitor to only collect new bounds for unique types. That is, if we have a type like:etc., the visitor used to end up collecting one WF obligation for each path from
T_Nto itsWhitespaceleaves, even though WF of a type (I believe) doesn't depend on the path the visitor took to get there, which allows us to deduplicate by Ty. Not deduplicating caused us to go O(2^N) here.next-solver is still about ~5x slower than the old solver on the third reproducer due to some other hidden quadratics, and fixing that seems to be more involved, but I think this PR will still be ✨ An Improvement.
r? lcnr