Skip to content

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

Merged
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
inq:obligations-self-ty-recompute-sub-root
Jun 9, 2026
Merged

obligations_for_self_ty: skip irrelevant goals (recompute sub_root from stalled_vars)#156187
rust-bors[bot] merged 5 commits into
rust-lang:mainfrom
inq:obligations-self-ty-recompute-sub-root

Conversation

@inq

@inq inq commented May 5, 2026

Copy link
Copy Markdown
Contributor

View all comments

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

rustbot commented May 5, 2026

Copy link
Copy Markdown
Collaborator

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)

@lcnr lcnr May 5, 2026

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.

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

lcnr commented May 5, 2026

Copy link
Copy Markdown
Contributor

@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

rust-bors Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

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

@rust-timer

This comment has been minimized.

@lcnr

lcnr commented May 5, 2026

Copy link
Copy Markdown
Contributor

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
fn pending_obligations(&self) -> PredicateObligations<'tcx>;

/// Returning all pending obligations which reference an inference
/// variable with `_sub_root`.

@BoxyUwU BoxyUwU Jun 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should explicitly state that this can be conservative and return obligations which don't reference sub root

View changes since the review

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.

Sorry for late update! Fixed, thank you!!

// Conservative here: if any of its stalled vars are not infer var anymore,
// some unification happened, so this goal is no longer stalled.
// So include it to re-evaluate in the downstream.
stalled_on.stalled_vars.iter().filter_map(|arg| arg.as_type()).any(

@BoxyUwU BoxyUwU Jun 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a comment about how we don't just use the sub roots from stalled_on as they may be out of date

View changes since the review

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.

Fixed! sorry for my bad english T.T

Comment thread compiler/rustc_trait_selection/src/solve/fulfill.rs
@BoxyUwU

BoxyUwU commented Jun 7, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 7, 2026
@rustbot

rustbot commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@inq inq force-pushed the obligations-self-ty-recompute-sub-root branch from 38cdf1c to 6287f19 Compare June 9, 2026 05:14
@rustbot

rustbot commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

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.

@inq

inq commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 9, 2026
@lcnr

lcnr commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@bors r=BoxyUwU,lcnr

@rust-bors

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 6287f19 has been approved by BoxyUwU,lcnr

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

Scheduling this before the next rollup, since there's few rollupable prs
@bors p=6

@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 9, 2026
@rust-bors

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: BoxyUwU,lcnr
Duration: 3h 32m 20s
Pushing beae781 to main...

@rust-bors rust-bors Bot merged commit beae781 into rust-lang:main Jun 9, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 057ed8b (parent) -> beae781 (this PR)

Test differences

Show 1 test diff

Stage 2

  • [run-make] tests/run-make/compressed-debuginfo-zstd: ignore (ignored if LLVM wasn't build with zstd for ELF section compression or LLVM is not the default codegen backend) -> pass (J0)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard beae781308e9ddef13074a03faf57ca2fac59a5b --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc-core-tests: 20m 54s -> 12m 51s (-38.5%)
  2. armhf-gnu: 1h 8m -> 1h 33m (+36.4%)
  3. dist-x86_64-llvm-mingw: 1h 54m -> 1h 14m (-35.0%)
  4. x86_64-gnu-stable: 3h 16m -> 2h 21m (-27.8%)
  5. dist-android: 23m 18s -> 29m 34s (+26.9%)
  6. pr-check-1: 43m 9s -> 31m 43s (-26.5%)
  7. pr-check-2: 54m 41s -> 42m 29s (-22.3%)
  8. x86_64-msvc-1: 2h 37m -> 2h 4m (-20.7%)
  9. x86_64-gnu: 3h 4m -> 2h 30m (-18.5%)
  10. aarch64-apple: 2h 55m -> 3h 25m (+17.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (beae781): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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)
-14.2% [-69.4%, -0.2%] 15
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -53.5%)

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)
- - 0
Improvements ✅
(secondary)
-53.5% [-87.1%, -1.4%] 5
All ❌✅ (primary) - - 0

Cycles

Results (secondary -48.4%)

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)
- - 0
Improvements ✅
(secondary)
-48.4% [-79.2%, -2.1%] 5
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 517.542s -> 523.273s (1.11%)
Artifact size: 400.80 MiB -> 400.81 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. 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.

7 participants