Skip to content

Fix TypeOutlives fast-path - #163576

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ShoyuVanilla:outlives-fast-path
Oct 2, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ShoyuVanilla:outlives-fast-path

Conversation

@ShoyuVanilla

@ShoyuVanilla ShoyuVanilla commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Oh, the fast path is scuffed here. So, I feel fairly confident that we can encounter cases where stalled_on is wrong due to region vars without there being a bug, as in, your change is correct and desirable, but this specific test is just a bug in the fast path:

<MaybeVerify as Service<?infer>>::Future: 'static should simply not be considered stalled. What's the cost of either entirely removing this trivially_stalled_on fast path or fixing it to bail when encountering non-rigid aliases

This change is correct. Please separately do a PR to fix the type-outlives fastpath 😊

Originally posted by @lcnr in #162782 (comment)

The first perf-run result is for always returning Outcome::NoFastPath on any infer var and the second one is for the current HEAD.

We shouldn't stall the outlives goal if the goal contains a non-rigid alias even though the goal contains a non-region infer. Non-fast path will normalize that non-rigid alias and that make the evaluation progress, and I think in theory the fast path shouldn't make observable difference outside the solver.

I'm not entirely sure on disabling fast path only in the presence of non-rigid opaques instead of disabling it entirely for non-region infer, but..

  • It's no-less-correct than the status quo
  • It roughly matches the actual non-fast path:
    if ty.has_non_region_infer() || ty.has_non_rigid_aliases() {
    self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
  • The later has some perf impact hard to ignore for typenum

I couldn't conjure up any case fixed by this PR other than the one in #162782 😅

r? lcnr

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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 Oct 1, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

@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 Oct 1, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 1, 2026
Do not stall outlives goals on infer vars in fast path
@rust-bors

rust-bors Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ff34d4b (ff34d4bb1acbe2d82c4a8089354f983739266bc7)
Base parent: 21b707e (21b707e3f97e0b522ebd2f277a862339625ad83f)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ff34d4b): 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 @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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)
2.3% [0.2%, 3.1%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

Results (primary -2.7%, secondary -20.1%)

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.7% [-3.1%, -2.2%] 2
Improvements ✅
(secondary)
-20.1% [-20.9%, -19.4%] 2
All ❌✅ (primary) -2.7% [-3.1%, -2.2%] 2

Binary size

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

Bootstrap: 487.961s -> 491.627s (0.75%)
Artifact size: 406.51 MiB -> 406.65 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 1, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

@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 Oct 2, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
Do not stall outlives goals on infer vars in fast path
@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5b8f953 (5b8f953674ed9146b762b22f2c98f0ec7bbba552)
Base parent: a5c10c3 (a5c10c39125788787370a1ab11c954b9dff37859)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5b8f953): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@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.2% [0.1%, 0.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -4.0%)

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)
-4.0% [-4.1%, -4.0%] 2
All ❌✅ (primary) - - 0

Cycles

Results (secondary 4.6%)

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)
10.0% [7.8%, 12.3%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.1% [-7.1%, -5.4%] 3
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.1%, secondary 0.1%)

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

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.2%] 107
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 91
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [0.0%, 0.2%] 107

Bootstrap: 490.07s -> 491.114s (0.21%)
Artifact size: 406.35 MiB -> 407.26 MiB (0.22%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Oct 2, 2026
@rust-cloud-vms
rust-cloud-vms Bot force-pushed the outlives-fast-path branch from 94684a2 to 9270acb Compare October 2, 2026 09:37
@ShoyuVanilla
ShoyuVanilla marked this pull request as ready for review October 2, 2026 10:02
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2026
@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

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

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 2, 2026
@ShoyuVanilla ShoyuVanilla changed the title Do not stall outlives goals on infer vars in fast path Fix TypeOutlives fast-path Oct 2, 2026
@lcnr

lcnr commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

this seems right, cool

the remaining perf impact seems like noise

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9270acb has been tentatively approved by lcnr

It will be put into the queue for this repository once PR CI succeeds.

@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 Oct 2, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 2, 2026
…=lcnr

Fix `TypeOutlives` fast-path

> Oh, the fast path is scuffed here. So, I feel fairly confident that we can encounter cases where stalled_on is wrong due to region vars without there being a bug, as in, your change is correct and desirable, but this specific test is just a bug in the fast path:
>
> `<MaybeVerify as Service<?infer>>::Future: 'static` should simply not be considered stalled. What's the cost of either entirely removing this trivially_stalled_on fast path or fixing it to bail when encountering non-rigid aliases
>
> This change is correct. Please separately do a PR to fix the type-outlives fastpath :blush:

_Originally posted by @lcnr in rust-lang#162782 (comment)

The first perf-run result is for always returning `Outcome::NoFastPath` on any infer var and the second one is for the current HEAD.

We shouldn't stall the outlives goal if the goal contains a non-rigid alias even though the goal contains a non-region infer. Non-fast path will normalize that non-rigid alias and that make the evaluation progress, and I think in theory the fast path shouldn't make observable difference outside the solver.

I'm not entirely sure on disabling fast path only in the presence of non-rigid opaques instead of disabling it entirely for non-region infer, but..

- It's no-less-correct than the status quo
- It roughly matches the actual non-fast path:
  https://github.com/rust-lang/rust/blob/dba8825fe50879b22129271fb865944e384f7cce/compiler/rustc_next_trait_solver/src/solve/mod.rs#L128-L129
- The later has some perf impact hard to ignore for `typenum`

I couldn't conjure up any case fixed by this PR other than the one in rust-lang#162782 😅

r? lcnr
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 2, 2026
…=lcnr

Fix `TypeOutlives` fast-path

> Oh, the fast path is scuffed here. So, I feel fairly confident that we can encounter cases where stalled_on is wrong due to region vars without there being a bug, as in, your change is correct and desirable, but this specific test is just a bug in the fast path:
>
> `<MaybeVerify as Service<?infer>>::Future: 'static` should simply not be considered stalled. What's the cost of either entirely removing this trivially_stalled_on fast path or fixing it to bail when encountering non-rigid aliases
>
> This change is correct. Please separately do a PR to fix the type-outlives fastpath :blush:

_Originally posted by @lcnr in rust-lang#162782 (comment)

The first perf-run result is for always returning `Outcome::NoFastPath` on any infer var and the second one is for the current HEAD.

We shouldn't stall the outlives goal if the goal contains a non-rigid alias even though the goal contains a non-region infer. Non-fast path will normalize that non-rigid alias and that make the evaluation progress, and I think in theory the fast path shouldn't make observable difference outside the solver.

I'm not entirely sure on disabling fast path only in the presence of non-rigid opaques instead of disabling it entirely for non-region infer, but..

- It's no-less-correct than the status quo
- It roughly matches the actual non-fast path:
  https://github.com/rust-lang/rust/blob/dba8825fe50879b22129271fb865944e384f7cce/compiler/rustc_next_trait_solver/src/solve/mod.rs#L128-L129
- The later has some perf impact hard to ignore for `typenum`

I couldn't conjure up any case fixed by this PR other than the one in rust-lang#162782 😅

r? lcnr
rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #163317 (Fix incremental compilation for fat LTO)
 - #163582 (Reapply "bootstrap: Enable rustdoc mergeable CCI for std and internal docs")
 - #151793 (Add mul_add_relaxed methods for floating-point types)
 - #162782 (Fix rustdoc ICE caused by mishandling of ambiguity errors)
 - #163010 (Miri can do dirfd now)
 - #163535 (Improve `DocStrings` perf)
 - #163576 (Fix `TypeOutlives` fast-path)
 - #163587 (Several small span improvements)
 - #163612 (fix `ValidateBoundVars`)
 - #163632 (bump rustc-build-sysroot)
 - #163635 (Revert note about signum of NaN)
 - #163644 (Add mailmap entry)
 - #163651 (Remove variants from `feature-gate-autodiff-use` test)
rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #163582 (Reapply "bootstrap: Enable rustdoc mergeable CCI for std and internal docs")
 - #151793 (Add mul_add_relaxed methods for floating-point types)
 - #162782 (Fix rustdoc ICE caused by mishandling of ambiguity errors)
 - #163010 (Miri can do dirfd now)
 - #163535 (Improve `DocStrings` perf)
 - #163576 (Fix `TypeOutlives` fast-path)
 - #163587 (Several small span improvements)
 - #163603 (Reorganise reflection intrinsics)
 - #163612 (fix `ValidateBoundVars`)
 - #163632 (bump rustc-build-sysroot)
 - #163635 (Revert note about signum of NaN)
 - #163644 (Add mailmap entry)
 - #163647 (Rename `rustc_driver::run_compiler` to `compiler_entrypoint`)
 - #163651 (Remove variants from `feature-gate-autodiff-use` test)
@rust-bors
rust-bors Bot merged commit 12e214a into rust-lang:main Oct 2, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 2, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 2, 2026
Rollup merge of #163576 - ShoyuVanilla:outlives-fast-path, r=lcnr

Fix `TypeOutlives` fast-path

> Oh, the fast path is scuffed here. So, I feel fairly confident that we can encounter cases where stalled_on is wrong due to region vars without there being a bug, as in, your change is correct and desirable, but this specific test is just a bug in the fast path:
>
> `<MaybeVerify as Service<?infer>>::Future: 'static` should simply not be considered stalled. What's the cost of either entirely removing this trivially_stalled_on fast path or fixing it to bail when encountering non-rigid aliases
>
> This change is correct. Please separately do a PR to fix the type-outlives fastpath :blush:

_Originally posted by @lcnr in #162782 (comment)

The first perf-run result is for always returning `Outcome::NoFastPath` on any infer var and the second one is for the current HEAD.

We shouldn't stall the outlives goal if the goal contains a non-rigid alias even though the goal contains a non-region infer. Non-fast path will normalize that non-rigid alias and that make the evaluation progress, and I think in theory the fast path shouldn't make observable difference outside the solver.

I'm not entirely sure on disabling fast path only in the presence of non-rigid opaques instead of disabling it entirely for non-region infer, but..

- It's no-less-correct than the status quo
- It roughly matches the actual non-fast path:
  https://github.com/rust-lang/rust/blob/dba8825fe50879b22129271fb865944e384f7cce/compiler/rustc_next_trait_solver/src/solve/mod.rs#L128-L129
- The later has some perf impact hard to ignore for `typenum`

I couldn't conjure up any case fixed by this PR other than the one in #162782 😅

r? lcnr
@ShoyuVanilla
ShoyuVanilla deleted the outlives-fast-path branch October 3, 2026 04:58
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 3, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#163582 (Reapply "bootstrap: Enable rustdoc mergeable CCI for std and internal docs")
 - rust-lang/rust#151793 (Add mul_add_relaxed methods for floating-point types)
 - rust-lang/rust#162782 (Fix rustdoc ICE caused by mishandling of ambiguity errors)
 - rust-lang/rust#163010 (Miri can do dirfd now)
 - rust-lang/rust#163535 (Improve `DocStrings` perf)
 - rust-lang/rust#163576 (Fix `TypeOutlives` fast-path)
 - rust-lang/rust#163587 (Several small span improvements)
 - rust-lang/rust#163603 (Reorganise reflection intrinsics)
 - rust-lang/rust#163612 (fix `ValidateBoundVars`)
 - rust-lang/rust#163632 (bump rustc-build-sysroot)
 - rust-lang/rust#163635 (Revert note about signum of NaN)
 - rust-lang/rust#163644 (Add mailmap entry)
 - rust-lang/rust#163647 (Rename `rustc_driver::run_compiler` to `compiler_entrypoint`)
 - rust-lang/rust#163651 (Remove variants from `feature-gate-autodiff-use` test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants