Do not increase depth when evaluating nested goals of NormalizesTo#157718
Conversation
This comment has been minimized.
This comment has been minimized.
| parent.required_depth = | ||
| parent.required_depth.max(match parent.increase_depth_for_nested { | ||
| IncreaseDepthForNested::Yes => required_depth_for_nested + 1, | ||
| IncreaseDepthForNested::No => required_depth_for_nested, | ||
| }); |
There was a problem hiding this comment.
I've been thinking about about this as this feels brittle. Instead of required_depth, could we change the search graph to track the "min_reached_available_depth" and then required depth is computed as "available_depth - min_reached_available_depth"
that way the way depth is actually tracked doesn't matter anymore
There was a problem hiding this comment.
Sounds good to me. I'll try that way 👍
e59d7fa to
dc07fda
Compare
| &mut self.stack, | ||
| step_kind_from_parent, | ||
| 0, | ||
| None, |
There was a problem hiding this comment.
can you put the min_reachable_for_nested in the UpdateParentGoalCtxt instead?
Hmm, this doesn't help it at all 🤔 |
|
Yeah, we only have |
|
oh 🤔 interesting xd do we have |
|
Yes, they do still exist. But we have very few of them anyway ( |
|
okay, so there are some other goals whose depth we don't properly increase in the old solver but now do in the new one 🤔 what a pain |
|
Indeed. I'll take a look this weekend |
dc07fda to
ee25de1
Compare
This comment has been minimized.
This comment has been minimized.
ee25de1 to
e23e501
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| UpdateParentGoalCtxt::Ordinary { nested_goals, min_reachable_available_depth } => { | ||
| parent.min_reached_available_depth = AvailableDepth( | ||
| parent.min_reached_available_depth.0.min(min_reachable_available_depth.0), | ||
| ); |
There was a problem hiding this comment.
can we just impl Ord for AvailableDepth to avoid accessing 0 here?
r=me on the change I think
It's unfortunate that this doesn't actually change things for wgpu, but still just seems vaguely desirable?
e23e501 to
464fb78
Compare
|
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. |
|
@bors r=lcnr |
…without-depth-increase, r=lcnr Do not increase depth when evaluating nested goals of `NormalizesTo` cc rust-lang#156619 (comment) ~~Only the last commit is relevant since this is based on rust-lang#156619~~ r? lcnr
Rollup of 6 pull requests Successful merges: - #157718 (Do not increase depth when evaluating nested goals of `NormalizesTo`) - #158449 (QNX target renaming) - #158483 (signed strict division: just use normal division) - #158516 ( Deduplicate codegen backends in bootstrap config) - #158542 (Rename `align` to `default_align` on `Scalar` and `Primitive`) - #158636 (linkchecker: upgrade to `html5ever v0.39`)
Rollup merge of #157718 - ShoyuVanilla:nested-normalizes-to-without-depth-increase, r=lcnr Do not increase depth when evaluating nested goals of `NormalizesTo` cc #156619 (comment) ~~Only the last commit is relevant since this is based on #156619~~ r? lcnr
|
Seems like this made compilation of typenum with the new solver 2x slower (#158639 (comment)). |
AFAIK, this PR doesn't regress the perf by its own, like making our trait solving algorithm less efficient.
This PR's intended effect is to increase the available recursion depth when we are dealing with normalization, and in theory, it can increase it by at most twice, when the search graph is a sheer chain of nested normalizations. So, I think the regression is direct outcome from the intention of this PR, rather than some sort of side effect. But 50% regression feels very unfortunate 😭 @lcnr Could you share your thoughts on this? |
|
🤣 I love it |
|
see rust-lang/trait-system-refactor-initiative#73 for what exactly is wrecking performance here |
There was a problem hiding this comment.
wait 😅 your doing something different than what I expected xd
I was thinking that we don't increase the depth of the NormalizesTo goal
as in
Projectionavailable_depth: 6NoramalizesToavailable_depth: 6 (do not increase depth)Traitavailable_depth: 5 (actually decrease)
not increasing the depth for the nested goals of normalization goals means that we don't slice off important parts of the search tree when encountering overflow, i.e
That slicing is necessary to avoid the exponential blowup in rust-lang/trait-system-refactor-initiative#73. Doing the thing I thought we are doing shouldn't be able to have such a perf impact 🤣
This comment was marked as off-topic.
This comment was marked as off-topic.
Oh, yeah.. looks like I've done things in a wrong way 🥲. I'll try it as you intended |
happens :3 i didn't catch it myself |
But I guess the perf impact wouldn't be that different (though regardless of this, I think doing things as you intended make sense) because it only shifts where the available depth is decreased/overflowed by a single step from the parent normalizes-to goal -> nested goal? I mean, if a nested goal of a normalizes-to is going to overflow in the correct implementation, the normalizes-to goal itself overflows in the current, wrong implementation and still divides the available depth, and if both of them is not going to overflow, then stepping into from that nested goal into its own nested goal will still decrease the available depth by 1? |
|
Unless I am mistaken here, this does matter imagine a |
Rollup of 6 pull requests Successful merges: - rust-lang/rust#157718 (Do not increase depth when evaluating nested goals of `NormalizesTo`) - rust-lang/rust#158449 (QNX target renaming) - rust-lang/rust#158483 (signed strict division: just use normal division) - rust-lang/rust#158516 ( Deduplicate codegen backends in bootstrap config) - rust-lang/rust#158542 (Rename `align` to `default_align` on `Scalar` and `Primitive`) - rust-lang/rust#158636 (linkchecker: upgrade to `html5ever v0.39`)
🤔 Oh, that makes sense. I'll try the correct way |
View all comments
cc #156619 (comment)
Only the last commit is relevant since this is based on #156619r? lcnr