Conversation
|
@nnethercote I avoided some of the redundant fulfillment checks where there was no change in the inference state |
|
I'm not expert enough with the trait solver to evaluate this. (@lcnr or @jdonszelmann might have opinions.) It does look like a fairly complex change without much explanation. Did you write the code yourself? |
I used the stalled goal fast path from #158249 and the try_evaluate_obligations work in #160479 |
|
this seems vaguely appropriate, the core idea "fast path if literally no infer var changed since last run" makes a lot of sense to me. The way it's written right now feels very brittle and I would like to encapsulate this somehow in a way that makes it harder to accidentally forget to check/update something. I considered separately having a shared list of what every goal in the fulfillment context is stalled on, so we dont need to iterate over it if literally nothing in it changed even if unrelated infer vars changed. Why do you not reset this counter when rolling back a snapshot. There's a lot of open design space here, think this is definitely a good direction :> |
|
One option is to store the "state after last fulfillment loop" in the That way you could also track "highest mentioned infer var indices" and "lowest constrained infer var" to ignore any constraints for infer vars which the fulfillment context is not stalled on. Idk if that matters :> |
|
@lcnr Thanks for your review I agree about the brittleness though |
but why? rolling them back should be completely correct, should it not? |
I am still unsure about this part but I think you are right here |
aec0740 to
20985b8
Compare
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rustbot ready |
|
@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.
Avoid redundant next-solver fulfillment scans
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (5d793fd): 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 -1.5%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 456.256s -> 463.808s (1.66%) |
20985b8 to
3761377
Compare
Avoid redundant next-solver fulfillment scans
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (e44f7f4): 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.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.1%, secondary 2.4%)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: 498.333s -> 497.609s (-0.15%) |
c8484be to
36016f3
Compare
|
@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.
Avoid redundant next-solver fulfillment scans
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (3857bb3): 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 -2.3%, secondary -5.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 1.2%)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: 497.193s -> 496.559s (-0.13%) |
|
for the #159933 style case the speedup stayed pretty consistent as the case got larger I got these results locally on I reran I don't think there's a larger regression hiding here |
| self.all_pending_trackable = false; | ||
| } | ||
| } else { | ||
| self.all_pending_trackable = false; |
There was a problem hiding this comment.
when is this the case
There was a problem hiding this comment.
this happens when at least one pending goal cannot be tracked through GoalStalledOn
we cannot know that the whole fulfillment context is safely stalled
in that case we avoid taking the generation fast path
36016f3 to
6c4a9ce
Compare
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
6c4a9ce to
b82a324
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. |
I considered this but kept the generation-based invalidation approach the generation tracks whether the recorded stalled state may be stale while the other fields track the conditions needed to safely use the fast path |
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
View all comments
Refs #159933
the slowdown comes from repeatedly walking the pending fulfillment queue even when nothing has changed that could make the stalled goals progress and to avoid that the inference context tracks changes that may unblock stalled goals
fulfillment remembers the generation after reaching a fixpoint and can skip another queue scan when the generation is unchanged and all pending goals are safe to track this way
relevant changes to type, const, int and float inference variables are tracked including type sub-unification
repeated changes are coalesced until fulfillment starts another pass and we do not keep updating the generation unnecessarily
the generation is also part of snapshot state and rolling back a snapshot restores it together with the inference state without adding an undo-log entry for every change
On the reproducer from issue against current status: