skip proving the trait goal if possible in NormalizesTo goal#149533
skip proving the trait goal if possible in NormalizesTo goal#149533adwinwhite wants to merge 3 commits intorust-lang:mainfrom
NormalizesTo goal#149533Conversation
also split the `assembly_and_merge_candidates` for `HostEffect` and `NormalizesTo`
There was a problem hiding this comment.
Not sure whether candidate preference matters to effect goal.
There was a problem hiding this comment.
it's whatever :> please add a FIXME(const_traits) to assemble_and_merge_candidates that this was copied from the old projection normalization behavior and might not be what we actually want here
| // | ||
| // We currently intentionally do not guide inference this way. | ||
| // Since we skip proving the trait goal in normalizes-to goal now, the normalizes-to | ||
| // goal can successfully resolve the infer var via param env. |
There was a problem hiding this comment.
This seems unavoidable since we don't know whether the trait goal will succeed or not at this time.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
fun, this isn't quite the behavior of the old trait solver either :3
the old solver only skips trying to prove the trait goal of we've got a builtin trait object impls. I think this ended up not really being necessary after your previous work?
idk... this sucks xd
let's see if the change impacts perf in a major way. If so, we can still avoid assembling impls in some cases at least :3
| D: SolverDelegate<Interner = I>, | ||
| I: Interner, | ||
| { | ||
| pub(super) fn normalize_trait_associated_term( |
There was a problem hiding this comment.
| pub(super) fn normalize_trait_associated_term( | |
| pub(super) fn normalize_projection_term( |
that's what we use in AliasTermKind 🤔
| // We currently intentionally do not guide inference this way. | ||
| // Since we skip proving the trait goal in normalizes-to goal now, the normalizes-to | ||
| // goal can successfully resolve the infer var via param env. | ||
| // This causes the stalled ambiguous trait goal to succeed as well. |
There was a problem hiding this comment.
this also doesn't compile with the old solver right now 🤔 why?
ah, because the old solver always uses assemble_candidates_from_impls and forces ambiguity unless assembly resulted in a builtin trait object candidate :<
that's wild xx
There was a problem hiding this comment.
I do think we should not merge this PR with this behavior change 🤔
We should check that the param_env trait candidates are not ambig. You could manually check that they are not, but unsure how to do so without eating a lot of the perf benefit again
| // We don't care about overflow. If proving the trait goal overflowed, then | ||
| // it's enough to report an overflow error for that, we don't also have to | ||
| // overflow during normalization. |
There was a problem hiding this comment.
| // We don't care about overflow. If proving the trait goal overflowed, then | |
| // it's enough to report an overflow error for that, we don't also have to | |
| // overflow during normalization. | |
| // We don't care about overflow. If proving the trait goal overflowed, then | |
| // it's enough to report an overflow error for that, we don't also have to | |
| // overflow for the const bound. |
or sth
There was a problem hiding this comment.
it's whatever :> please add a FIXME(const_traits) to assemble_and_merge_candidates that this was copied from the old projection normalization behavior and might not be what we actually want here
| // If we're normalizing an GAT, we bail if using a where-bound would constrain | ||
| // its generic arguments. | ||
| // FIXME(generic_associated_types): Addresses aggressive inference in #92917. |
There was a problem hiding this comment.
flip these two statements. I want the comment to start with the FIXME. Right now it seems like the first line is separate from the content of the FIXME
| &mut self, | ||
| goal: Goal<I, ty::NormalizesTo<I>>, | ||
| ) -> QueryResult<I> { | ||
| let (mut candidates, _) = |
There was a problem hiding this comment.
comment: something something we already looked for param_env and alias-bound candidates so we don't have to assemble them again
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
skip proving the trait goal if possible in `NormalizesTo` goal
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (405e127): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @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 (secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -21.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 469.029s -> 471.041s (0.43%) |
| // ambiguous fallback candidate. It happens to be this object assembly call | ||
| // here. | ||
| let (candidates, _) = | ||
| self.assemble_and_evaluate_candidates(goal, AssembleCandidatesFrom::Object); |
There was a problem hiding this comment.
Moved object candidate out of the fast path to avoid coherence issues.
There was a problem hiding this comment.
which coherence issue? what's the difference between EnvAndBounds and EnvAndBoundsFastPath?
There was a problem hiding this comment.
ah I see. That structure feels odd and unintuitive 🤔
maybe we should do an even larger refactoring 🤔 make normalize self ty + opaque types jank a sub-fn returning an Option for the "self ty is infer" case, and then use that directly.
Would need to think about the structure more myself, but I do think having a bunch of control flow inside of our functions makes code hard to understand and duplicating (parts of) the behavior may be better here.
|
☔ The latest upstream changes (presumably #154637) made this pull request unmergeable. Please resolve the merge conflicts. |
And also split
assembly_and_merge_candidatesforHostEffectandNormalizesTogoals.r? @lcnr