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

Pass list of defineable opaque types into canonical queries #122077

Merged
merged 13 commits into from
Apr 9, 2024

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Mar 6, 2024

This eliminates DefiningAnchor::Bubble for good and brings the old solver closer to the new one wrt cycles and nested obligations. At that point the difference between DefiningAnchor::Bind([]) and DefiningAnchor::Error was academic. We only used the difference for some sanity checks, which actually had to be worked around in places, so I just removed DefiningAnchor entirely and just stored the list of opaques that may be defined.

fixes #108498
fixes #116877

@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 labels Mar 6, 2024
@oli-obk

This comment was marked as outdated.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 6, 2024
@bors

This comment was marked as outdated.

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 6, 2024
Pass list of defineable opaque types into canonical queries

based on rust-lang#121796

This eliminates `DefiningAnchor::Bubble` for good and brings the old solver closer to the new one wrt cycles and nested obligations.

r? `@ghost`
@@ -320,5 +320,6 @@ fn response_no_constraints_raw<'tcx>(
external_constraints: tcx.mk_external_constraints(ExternalConstraintsData::default()),
certainty,
},
defining_anchor: Default::default(),
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 one is fishy, we can probably always pass in the anchor from the InferCtxt

let (infcx, key, canonical_inference_vars) = self
.with_opaque_type_inference(DefiningAnchor::Bubble)
.build_with_canonical(DUMMY_SP, canonical_key);
let (infcx, key, canonical_inference_vars) =
self.build_with_canonical(DUMMY_SP, canonical_key);
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 is the core change of this PR. Canonical queries now always use the anchor of their caller

@rust-log-analyzer

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@rust-timer

This comment has been minimized.

@@ -340,10 +340,10 @@ macro_rules! define_callbacks {
<$($K)* as keys::Key>::CacheSelector as CacheSelector<'tcx, Erase<$V>>
>::Cache;

// Ensure that keys grow no larger than 64 bytes
// Ensure that keys grow no larger than 72 bytes
Copy link
Member

Choose a reason for hiding this comment

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

Is this not a hard limit? Why was this added in the first place?

Copy link
Contributor Author

@oli-obk oli-obk Mar 6, 2024

Choose a reason for hiding this comment

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

probably perf, but I'm trying to resolve it anyway before going out of draft. I looked up the original PR, and it was just for not accidentally growing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I'm a bit stuck on CanonicalTypeOpAscribeUserTypeGoal. It's 8 bytes too large now, but there's also nothing that stands out as "this should be interned". Just moving something onto a TyCtxt arena doesn't really seem right to me, that's just avoiding the above size check without adhering to its spirit.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 6, 2024
@oli-obk oli-obk force-pushed the eager_opaque_checks4 branch 3 times, most recently from c9357a9 to 05ee8ae Compare March 7, 2024 21:35
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 8, 2024

☔ The latest upstream changes (presumably #122151) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Mar 8, 2024

☔ The latest upstream changes (presumably #122182) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 11, 2024

@bors try

@bors
Copy link
Contributor

bors commented Mar 11, 2024

⌛ Trying commit cb7c75b with merge e34498b...

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 8, 2024

@bors r=lcnr rollup=never

@bors
Copy link
Contributor

bors commented Apr 8, 2024

📌 Commit dc97b1e has been approved by lcnr

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 8, 2024
@bors
Copy link
Contributor

bors commented Apr 8, 2024

⌛ Testing commit dc97b1e with merge b234e44...

@bors
Copy link
Contributor

bors commented Apr 9, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing b234e44 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 9, 2024
@bors bors merged commit b234e44 into rust-lang:master Apr 9, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 9, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b234e44): comparison URL.

Overall result: ❌ regressions - 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)
1.9% [0.2%, 5.4%] 101
Regressions ❌
(secondary)
2.3% [0.3%, 4.7%] 77
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.8% [-0.6%, 5.4%] 102

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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.7% [-2.5%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.7% [-2.5%, -0.9%] 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)
2.5% [1.1%, 5.2%] 55
Regressions ❌
(secondary)
3.0% [1.1%, 5.2%] 41
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.5% [1.1%, 5.2%] 55

Binary size

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

Bootstrap: 669.403s -> 674.046s (0.69%)
Artifact size: 318.50 MiB -> 318.46 MiB (-0.01%)

@oli-obk oli-obk deleted the eager_opaque_checks4 branch April 9, 2024 04:52
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 9, 2024

hmm weird, a previous perf run was clean. I must have changed something since then. I'll investigate.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 9, 2024

Ah... dd72bf9

Scraping regions is expensive.

I'll implement an alternative. Let's not revert this PR, it's an important bugfix and blocker of a lot of follow up work

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)
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. 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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet