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

Avoid a scrape_region_constraints and instead register the region constraints directly #123669

Closed
wants to merge 2 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 9, 2024

Should fix the perf regression from #122077 (comment)

@rustbot

This comment was marked as resolved.

@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. labels Apr 9, 2024
@oli-obk

This comment was marked as resolved.

@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 Apr 9, 2024
@bors
Copy link
Contributor

bors commented Apr 9, 2024

⌛ Trying commit 28df1d3 with merge de35723...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 9, 2024
Avoid a scrape_region_constraints and instead register the region constraints directly

Should fix the perf regression from rust-lang#122077 (comment)
@bors
Copy link
Contributor

bors commented Apr 9, 2024

☀️ Try build successful - checks-actions
Build commit: de35723 (de3572333ef2b89ac84b15d5e540a36499f3bb3c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (de35723): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

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

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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.9% [-5.0%, -0.2%] 94
Improvements ✅
(secondary)
-2.3% [-4.6%, -0.4%] 69
All ❌✅ (primary) -1.9% [-5.0%, -0.2%] 94

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)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.7% [2.7%, 2.7%] 1

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)
2.0% [1.1%, 4.0%] 23
Regressions ❌
(secondary)
2.9% [2.2%, 3.6%] 7
Improvements ✅
(primary)
-2.2% [-4.8%, -0.9%] 45
Improvements ✅
(secondary)
-2.9% [-4.0%, -1.3%] 19
All ❌✅ (primary) -0.8% [-4.8%, 4.0%] 68

Binary size

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

Bootstrap: 674.109s -> 672.163s (-0.29%)
Artifact size: 318.37 MiB -> 318.30 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 9, 2024
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 9, 2024

yay

@compiler-errors
Copy link
Member

How does this fix the original issue that this scrape was added for? Didn't a bunch of crates ICE in crater? Did we ever minimize them down to UI tests?

@compiler-errors
Copy link
Member

Oh, I see that it's equating the opaque manually... I wonder if that's sound wrt generalization.

{
assert_eq!(alias_ty.args.len(), opaque_type_key.args.len());
for (key_arg, hidden_arg) in
opaque_type_key.args.iter().zip(alias_ty.args.iter())
Copy link
Member

Choose a reason for hiding this comment

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

This isnt taking into account variance is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, but that shouldn't matter here in practice, as all the args are either params or inference vars. Well, they should be. Unfortunately in the presence of erroneous code we may not have errored yet, as that only happens at the end of borrowck.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 9, 2024

Did we ever minimize them down to UI tests?

Yes (tests/ui/impl-trait/nested-hkl-lifetime.rs), and I confirmed it registers lifetimes and fails in borrowck with the ICE we saw on crater (unless we scrape or do this PR)

@compiler-errors
Copy link
Member

kinda unsure about the subtleties of equating args when instantiating queries

r? lcnr

@rustbot rustbot assigned lcnr and unassigned compiler-errors Apr 9, 2024
@lcnr
Copy link
Contributor

lcnr commented Apr 9, 2024

It feels like it adds a new (implicit) invariant to canonical goals. Want to think about how to make that more explicit. I think it's currently "you're allowed to use eq as long one of the sides is an infer var, otherwise use equate_generic_arg"?

This sort of invariant feels non-trivial to me and I would like it to be more clearly laid out. Maybe we can also simplify it to always use a different equate and forbid using eq directly?

Would look more deeply into it once I am back from ETAPS and maybe chat in sync about this a bit

@apiraino
Copy link
Contributor

To all: is this waiting on #120700 or other design? thanks

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 26, 2024

I need to put in some thought into how to harden canonical goal result processing against doing things we don't want it to. I'd rather not rely on policy, but just hide the InferCtxt entirely behind a limited API we know to behave correctly

@apiraino apiraino 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 26, 2024
@lcnr
Copy link
Contributor

lcnr commented Aug 14, 2024

The perf impact has been meaningful, I am however fairly uncomfortable with merging this PR as stated above.

With the new solver we'll likely want to perform pretty much all type-ops locally again as the new trait solver has a far better global cache. In this case keeping the outer scrape_region_constraints has a far smaller impact.

If we were to go and lean into this scrape_region_constraints we should remove type_op_eq and type_op_subtype and always do them locally, even with the old solver. Canonicalizing just to equate types very much does not feel worth it to me

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2024
…cx, r=<try>

`ParamEnvAnd::fully_perform`: we have an `ocx`, use it

cc rust-lang#123669

r? `@compiler-errors`
@oli-obk oli-obk closed this Aug 14, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Aug 16, 2024
…-ocx, r=compiler-errors

`ParamEnvAnd::fully_perform`: we have an `ocx`, use it

cc rust-lang#123669

r? `@compiler-errors`
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Aug 16, 2024
…-ocx, r=compiler-errors

`ParamEnvAnd::fully_perform`: we have an `ocx`, use it

cc rust-lang#123669

r? ``@compiler-errors``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 16, 2024
Rollup merge of rust-lang#129078 - lcnr:scrape_region_constraints-use-ocx, r=compiler-errors

`ParamEnvAnd::fully_perform`: we have an `ocx`, use it

cc rust-lang#123669

r? ``@compiler-errors``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants