Skip to content

obligations_for_self_ty: skip irrelevant goals (recompute sub_root from stalled_vars)#156187

Open
inq wants to merge 4 commits intorust-lang:mainfrom
inq:obligations-self-ty-recompute-sub-root
Open

obligations_for_self_ty: skip irrelevant goals (recompute sub_root from stalled_vars)#156187
inq wants to merge 4 commits intorust-lang:mainfrom
inq:obligations-self-ty-recompute-sub-root

Conversation

@inq
Copy link
Copy Markdown
Contributor

@inq inq commented May 5, 2026

Supersedes #146759. Since the original PR is having conflict now, I've rebased.

This includes 2 commit

  1. the original one with rebase
  2. above that, I've changed:
if stalled_on is Some: ignore sub_roots -> walk stalled_vars -> re-evaluate sub_root 
else: same with this PR

Why:
cached sub_roots can be stale if there is a sub-unification merge after stalling (lcnr proposed on the original PR)
so re-evaluating when reads ---> so more conservative

Testing:

Style question:

In my preference, inside filter, I used filter_map - matches, but do you prefer if-let chain?

Original author: lcnr #146759

r? @lcnr 

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

changes to inspect_obligations.rs

cc @lcnr

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels May 5, 2026
@rustbot

This comment has been minimized.

@inq inq force-pushed the obligations-self-ty-recompute-sub-root branch from 90c0853 to 596f7e9 Compare May 5, 2026 12:03
.filter(|(_, stalled_on)| {
let Some(stalled_on) = stalled_on else { return true };
stalled_on.stalled_vars.iter().filter_map(|arg| arg.as_type()).any(|ty| {
matches!(*ty.kind(), ty::Infer(ty::TyVar(tv)) if infcx.sub_unification_table_root_var(tv) == vid)
Copy link
Copy Markdown
Contributor

@lcnr lcnr May 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please shallow_resolve the stalled_var here and if it is not an inference variable, always return true for now.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, please add a comment explaining that we are conservative here and want to handle cases where a goal is no longer stalled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added! thank you!

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented May 5, 2026

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
…=<try>

obligations_for_self_ty: skip irrelevant goals (recompute sub_root from stalled_vars)
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 5, 2026

☀️ Try build successful (CI)
Build commit: 1a8e5b7 (1a8e5b75d2437597d5622146fe1d722a41e373c6, parent: 4feb7221f4d445120a5061b16ce7222adbfdf6f6)

@rust-timer

This comment has been minimized.

@lcnr
Copy link
Copy Markdown
Contributor

lcnr commented May 5, 2026

r? BoxyUwU

given that it's largely my PR, let's give it to somebody else to review

@rustbot rustbot assigned BoxyUwU and unassigned lcnr May 5, 2026
@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1a8e5b7): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-17.6% [-51.4%, -0.5%] 9
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -2.4%, secondary -67.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-67.8% [-90.8%, -0.5%] 4
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

Results (secondary -25.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-29.4% [-67.4%, -0.6%] 7
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 495.518s -> 495.667s (0.03%)
Artifact size: 394.42 MiB -> 394.40 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants