Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split NormalizesTo out of Projection 3 #118725

Merged
merged 5 commits into from
Dec 8, 2023

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Dec 7, 2023

third attempt at #112658. Rebasing #116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since #117088.

see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg

fixes rust-lang/trait-system-refactor-initiative#1

r? @compiler-errors

@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 Dec 7, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2023

Some changes occurred to the core trait solver

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

@rust-log-analyzer

This comment has been minimized.

@lcnr lcnr force-pushed the normalizes-to-projection-split-3 branch from 5c0809e to ffb4c08 Compare December 8, 2023 00:31
@@ -1,5 +1,7 @@
// compile-flags: -Ztrait-solver=next
// known-bug: trait-system-refactor-initiative#60
// dont-check-failure-status
// dont-check-compiler-stderr
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test now ICEs, but given that it's already buggy I don't want this to block merging this PR. Will look at it separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would be fixed by actually reporting errors in writeback if normalization fails. Unfortunately that ICEs because regions have already been resolved. Will do this in a separate PR, temp diff 193abb3

match a_ty.kind() {
&ty::Alias(ty::AliasKind::Projection, data) => {
// FIXME: This does not handle subtyping correctly, we should switch to
// alias-relate in the new solver and could instead create a new inference
Copy link
Member

Choose a reason for hiding this comment

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

we do use alias relate in the new solver like 2 lines above. is this still relevant?

@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 8, 2023

r? @BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned compiler-errors Dec 8, 2023
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 8, 2023

@bors r+ rollup=never p=1 (i dont trust adding new predicate kinds to not be conflicty and also i mgiht be perf)

@bors
Copy link
Contributor

bors commented Dec 8, 2023

📌 Commit ac50f4b has been approved by BoxyUwU

It is now in the queue for this repository.

@bors bors 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 Dec 8, 2023
@bors
Copy link
Contributor

bors commented Dec 8, 2023

⌛ Testing commit ac50f4b with merge 21982a4...

@bors
Copy link
Contributor

bors commented Dec 8, 2023

☀️ Test successful - checks-actions
Approved by: BoxyUwU
Pushing 21982a4 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 8, 2023
@bors bors merged commit 21982a4 into rust-lang:master Dec 8, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 8, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (21982a4): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.9%] 17
Regressions ❌
(secondary)
0.3% [0.2%, 0.3%] 3
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-2.6%, 0.9%] 18

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 2
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) 0.1% [-0.4%, 0.6%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 675.561s -> 673.716s (-0.27%)
Artifact size: 314.00 MiB -> 314.08 MiB (0.03%)

@rustbot rustbot added the perf-regression Performance regression. label Dec 8, 2023
@BoxyUwU BoxyUwU added the perf-regression-triaged The performance regression has been triaged. label Dec 8, 2023
@BoxyUwU
Copy link
Member

BoxyUwU commented Dec 8, 2023

probably caused by adding the new PredicateKind. looks small and we need this for new solver so 🤷‍♀️

@lcnr lcnr deleted the normalizes-to-projection-split-3 branch December 8, 2023 06:59
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2023
perf: experiment with only non-functional changes from rust-lang#118725

cc rust-lang#118735

r? `@ghost`
@aliemjay
Copy link
Member

aliemjay commented Dec 8, 2023

callgrind diff of bors builds:

Ir1 Called1 Ir2 Called2 function
7,225,289,206 -- +26,998,798 -- Total for serde-1.0.136-Check-full
104,905,987 184,425 +7,130,548 +0 <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::register_predicate_obligation:???
191,337,918 137,023 +5,772,202 +0 <rustc_middle::ty::ParamEnv as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>:???
177,171,243 1,337,430 +5,230,173 +0 <rustc_middle::ty::context::CtxtInterners>::intern_predicate:???
39,833,350 243,002 +1,776,212 +0 <rustc_middle::ty::Clause as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with::<rustc_middle::ty::generic_args::ArgFolder>:???

The regressed crates are exactly the ones that benefit the most from #117749 where predicate interning and folding is very hot. I don't think there is much that can be done to mitigate the impact. Each function runtime has increased by few instructions as expected but that's enough to make a difference because of how much hot they are.

@lcnr consider reviewing #117749 to repent for your sin :)

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2023
refactor infer var storage

cleanup the code, discovered while working on rust-lang#118725
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2023
refactor writeback: emit normalization errors with new solver

implements rust-lang#118725 (comment)

r? `@compiler-errors` `@BoxyUwU` whoever comes first n stuff
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 12, 2023
…rrors

refactor infer var storage

cleanup the code, discovered while working on rust-lang#118725
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 12, 2023
…rors

refactor writeback: emit normalization errors with new solver

implements rust-lang#118725 (comment)

r? `@compiler-errors` `@BoxyUwU` whoever comes first n stuff
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 14, 2023
…, r=lcnr

Unconditionally register alias-relate in projection goal

Follow-up to rust-lang#118725, which subtly broke closure signature inference on combinators like `Result::map` which I noticed in syn.

Essentially, instead of using `eq` which will eagerly infer `?1 := <?2 as Trait>::Assoc`, we can directly emit an alias-relate goal, which will stay ambiguous for as long as `?2` is ambiguous.

This also more closely models the conceptual framing that projects-to acts like an alias-relate when solving, and like a normalizes-to when in a param env.

r? lcnr
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 14, 2023
…, r=lcnr

Unconditionally register alias-relate in projection goal

Follow-up to rust-lang#118725, which subtly broke closure signature inference on combinators like `Result::map` which I noticed in syn.

Essentially, instead of using `eq` which will eagerly infer `?1 := <?2 as Trait>::Assoc`, we can directly emit an alias-relate goal, which will stay ambiguous for as long as `?2` is ambiguous.

This also more closely models the conceptual framing that projects-to acts like an alias-relate when solving, and like a normalizes-to when in a param env.

r? lcnr
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2023
Rollup merge of rust-lang#118914 - compiler-errors:eager-alias-relate, r=lcnr

Unconditionally register alias-relate in projection goal

Follow-up to rust-lang#118725, which subtly broke closure signature inference on combinators like `Result::map` which I noticed in syn.

Essentially, instead of using `eq` which will eagerly infer `?1 := <?2 as Trait>::Assoc`, we can directly emit an alias-relate goal, which will stay ambiguous for as long as `?2` is ambiguous.

This also more closely models the conceptual framing that projects-to acts like an alias-relate when solving, and like a normalizes-to when in a param env.

r? lcnr
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

normalizes-to bound in old solver is stronger than new solver
8 participants