Skip to content

-Znext-solver Less normalizes-to janks#156619

Open
ShoyuVanilla wants to merge 8 commits into
rust-lang:mainfrom
ShoyuVanilla:less-normalizes-to-jank
Open

-Znext-solver Less normalizes-to janks#156619
ShoyuVanilla wants to merge 8 commits into
rust-lang:mainfrom
ShoyuVanilla:less-normalizes-to-jank

Conversation

@ShoyuVanilla

@ShoyuVanilla ShoyuVanilla commented May 15, 2026

Copy link
Copy Markdown
Member

@rustbot

rustbot commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

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

changes to inspect_obligations.rs

cc @lcnr

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@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 15, 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 May 15, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 15, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

I haven't done the nested goals' recursion depth part yet 😅 I'm gonna work on it if the overall design here pan out to be feasible

@rust-bors

rust-bors Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d4c528b (d4c528b37c59bf04c41ddba6375584d284d1a9ba, parent: 88ba7fbe0a6eda36e0adbfd0482856f3784031b9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d4c528b): 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
@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.4% [0.3%, 0.8%] 7
Regressions ❌
(secondary)
22.5% [0.6%, 46.0%] 12
Improvements ✅
(primary)
-0.3% [-0.7%, -0.1%] 20
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.2%] 29
All ❌✅ (primary) -0.1% [-0.7%, 0.8%] 27

Max RSS (memory usage)

Results (primary 1.5%, secondary 8.5%)

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

mean range count
Regressions ❌
(primary)
1.5% [0.9%, 2.6%] 5
Regressions ❌
(secondary)
11.4% [2.0%, 25.8%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-14.8% [-14.8%, -14.8%] 1
All ❌✅ (primary) 1.5% [0.9%, 2.6%] 5

Cycles

Results (secondary 26.9%)

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)
26.9% [17.5%, 41.5%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 510.626s -> 509.733s (-0.17%)
Artifact size: 398.07 MiB -> 398.06 MiB (-0.00%)

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

Copy link
Copy Markdown
Member Author

Oh, the perf regressions are insane 😅 I'll look into them

@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 May 16, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 16, 2026
@rust-bors

rust-bors Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 52311d2 (52311d29eb5b4b58f67e481749703829fab93a19, parent: 35143615544ede08a47947901cd4a6b7c5ecd450)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (52311d2): 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
@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.8% [0.2%, 1.2%] 8
Regressions ❌
(secondary)
26.5% [0.1%, 45.5%] 10
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 23
Improvements ✅
(secondary)
-0.4% [-0.8%, -0.2%] 29
All ❌✅ (primary) 0.0% [-0.3%, 1.2%] 31

Max RSS (memory usage)

Results (primary 1.7%, secondary 8.4%)

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

mean range count
Regressions ❌
(primary)
1.7% [1.0%, 2.8%] 6
Regressions ❌
(secondary)
11.3% [2.1%, 25.8%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-14.7% [-14.7%, -14.7%] 1
All ❌✅ (primary) 1.7% [1.0%, 2.8%] 6

Cycles

Results (primary 2.3%, secondary 22.5%)

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

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
25.0% [2.4%, 43.8%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 2.3% [2.3%, 2.3%] 1

Binary size

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

Bootstrap: 513.812s -> 509.975s (-0.75%)
Artifact size: 398.43 MiB -> 400.31 MiB (0.47%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 16, 2026
@ShoyuVanilla ShoyuVanilla force-pushed the less-normalizes-to-jank branch from 6bd6498 to 5927eca Compare May 28, 2026 15:43
@rustbot

This comment has been minimized.

@ShoyuVanilla

Copy link
Copy Markdown
Member Author

If my observation is correct, this would fix the perf regression 🤔
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (bf09da4): 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
@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.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
30.9% [30.9%, 31.0%] 3
Improvements ✅
(primary)
-0.2% [-0.5%, -0.1%] 40
Improvements ✅
(secondary)
-1.0% [-5.5%, -0.1%] 49
All ❌✅ (primary) -0.2% [-0.5%, 0.4%] 41

Max RSS (memory usage)

Results (primary 2.4%, secondary 6.0%)

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

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
13.7% [0.8%, 25.8%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.5% [-17.1%, -1.4%] 4
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Cycles

Results (secondary 3.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)
29.2% [28.9%, 29.5%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.6% [-6.0%, -2.1%] 11
All ❌✅ (primary) - - 0

Binary size

Results (secondary -0.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)
-0.0% [-0.0%, -0.0%] 3
All ❌✅ (primary) - - 0

Bootstrap: 514.669s -> 514.548s (-0.02%)
Artifact size: 400.66 MiB -> 400.59 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 5, 2026
@ShoyuVanilla

Copy link
Copy Markdown
Member Author

@lcnr I've done available depth hacks as well. Could this be reviewed or would you like me to completely remove all the remaining AliasRelate goals and remove that variant from ClauseKind as well? (They have been removed from normalizations but some are still remaining in places like solver relations)

@rust-bors

This comment has been minimized.

@ShoyuVanilla ShoyuVanilla force-pushed the less-normalizes-to-jank branch from 5c1e975 to 44d974b Compare June 9, 2026 18:18
@rustbot

This comment has been minimized.

@ShoyuVanilla

Copy link
Copy Markdown
Member Author

Re-measuring perf regressions on top of #156187

@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 Jun 9, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 9, 2026
@rust-bors

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 4d1f2a6 (4d1f2a670491cb7f00859ca676d850b5e49c41cb, parent: beae781308e9ddef13074a03faf57ca2fac59a5b)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4d1f2a6): 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
@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.4% [0.2%, 0.8%] 8
Improvements ✅
(primary)
-0.2% [-0.5%, -0.1%] 26
Improvements ✅
(secondary)
-1.0% [-5.6%, -0.1%] 47
All ❌✅ (primary) -0.2% [-0.5%, -0.1%] 26

Max RSS (memory usage)

Results (secondary -1.9%)

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)
2.4% [0.8%, 5.5%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-16.9%, -0.4%] 7
All ❌✅ (primary) - - 0

Cycles

Results (secondary -4.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)
-4.4% [-5.5%, -2.9%] 8
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 523.273s -> 517.628s (-1.08%)
Artifact size: 400.81 MiB -> 400.74 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 9, 2026

@lcnr lcnr left a comment

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.

Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs Outdated
Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs Outdated
/// Because of this we return any ambiguous nested goals from `NormalizesTo` to the
/// caller when then adds these to its own context. The caller is always an `AliasRelate`
/// caller when then adds these to its own context. The caller is always an `Projection`
/// goal so this never leaks out of the solver.

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.

can you more completely rewrite this comment and also state that NormalizesTo is just an implementation detail of Projection for associated terms

I feel like NormalizesTois just somewhat of a bad name xx

It should be something like
ProjectionComputeAssocTermCandidate or NormalizeAssocTermInternal or whatever :>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure. Would you like to change both this variant and the NormalizesTo goal's names into one of those more proper ones?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just changed the name of CurrentGoalKind::NormalizesTo for now and left PredicateKind::NormalizesTo as a FIXME for now 😅

Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs Outdated
self.normalization_goal_source,
Goal::new(self.cx(), self.param_env, normalizes_to),
Goal::new(self.cx(), self.param_env, projection),
false,

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.

hmm, I guess it's fine for now. Can you add a FIXME that this whole folder should be removed in favor of proper normalization, cc #156742

normalizes_to,
None,
IncreaseDepthForNested::No,
)?;

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.

comments please :3

  • why do we use a separate goal only for associated terms
  • why do we not increase the depth for nested goals
  • edge case that we don't reevaluate the NormalizesTo if equating the unconstrained_term afterwards reesults in inference constraints in the impl headerl, and how that should be fine as we will reevaluate the outer Projectiongoal in that case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added comments but I'm not totally sure my understandings on those questions are correct 😅

Comment thread compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
Comment thread compiler/rustc_type_ir/src/search_graph/mod.rs Outdated
Comment thread compiler/rustc_type_ir/src/search_graph/mod.rs Outdated
@ShoyuVanilla ShoyuVanilla force-pushed the less-normalizes-to-jank branch from 44d974b to ed986a6 Compare June 10, 2026 15:42
@rustbot

rustbot commented Jun 10, 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.

@ShoyuVanilla ShoyuVanilla force-pushed the less-normalizes-to-jank branch from ed986a6 to 1dad181 Compare June 10, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. 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.

4 participants