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

[PERF] allow region unification to change region universes #108867

Closed
wants to merge 4 commits into from

Conversation

aliemjay
Copy link
Member

@aliemjay aliemjay commented Mar 7, 2023

forked from #108121.

r? @ghost

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 7, 2023
@compiler-errors
Copy link
Member

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

bors commented Mar 8, 2023

⌛ Trying commit 4cb44a7 with merge 1bced552f1758b8f979780b55c326f0a39c51181...

@bors
Copy link
Contributor

bors commented Mar 8, 2023

☀️ Try build successful - checks-actions
Build commit: 1bced552f1758b8f979780b55c326f0a39c51181 (1bced552f1758b8f979780b55c326f0a39c51181)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1bced552f1758b8f979780b55c326f0a39c51181): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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.7% [0.7%, 0.8%] 2
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-3.1% [-4.2%, -0.6%] 9
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

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)
-4.1% [-4.1%, -4.1%] 1
Improvements ✅
(secondary)
-6.4% [-8.4%, -5.3%] 6
All ❌✅ (primary) -4.1% [-4.1%, -4.1%] 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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.2% [-6.5%, -5.9%] 6
All ❌✅ (primary) - - 0

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 8, 2023
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

unhappy to have the universe both in the var_infos and in the inference data. I don't think we should error eagerly for universe errors when equating universes because the new solver erases the universe of regions in the argument. THis makes adding universe to the UnifiedRegion really cumbersome I think. It's different for https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/type_variable/enum.TypeVariableValue.html and consts.

Unless you now prefer this approach, I would go ahead with #108121. Thank you for actually looking into my suggestion even though you disagreed ❤️

pub struct UnifiedRegion<'tcx> {
pub universe: ty::UniverseIndex,
pub value: Option<ty::Region<'tcx>>,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

similar to TypeVariableValue and ConstVariableValue change this to an enum and only have a universe in the Unknown case? 🤔

Copy link
Member Author

@aliemjay aliemjay Mar 8, 2023

Choose a reason for hiding this comment

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

although it seems redundant, but I thought it might be a good idea to store the universe of universals and existentials in the same place.

Copy link
Contributor

Choose a reason for hiding this comment

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

if region unification is infallible i think we even have to keep the universe even if value is Some, don't we? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. universe field here is redundant if value is Some.

(None, None) => *value1,
})
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, Self::Error> {
Ok(cmp::min_by_key(*value1, *value2, |val| (val.universe, val.value.is_none())))
Copy link
Contributor

Choose a reason for hiding this comment

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

this can pull down the universe of known regions which seems wrong 🤔 I would expect us to have to eagerly error here if we relate with a known region

Copy link
Member Author

@aliemjay aliemjay Mar 8, 2023

Choose a reason for hiding this comment

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

The idea is that unification should always be infallible, the constraint graph will eventually emit a universe error in this case.

The only invariant we should maintain in the unification table is that an existential cannot resolve to a region in a higher universe (plus one nice thing to have is to prefer universals over existentials within the same universe, but that's not necessary for soundness).

@aliemjay
Copy link
Member Author

aliemjay commented Mar 8, 2023

Unless you now prefer this approach, I would go ahead with #108121. Thank you for actually looking into my suggestion even though you disagreed heart

Indeed I prefer the approach :) but I'll go ahead and land #108121 first to unblock my other PRs and we'll get back to this later.

@jyn514
Copy link
Member

jyn514 commented Mar 8, 2023

@craterbot run mode=check-only

@craterbot
Copy link
Collaborator

👌 Experiment pr-108867 created and queued.
🤖 Automatically detected try build 1bced552f1758b8f979780b55c326f0a39c51181
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 8, 2023
@craterbot
Copy link
Collaborator

🚧 Experiment pr-108867 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-108867 is completed!
📊 15 regressed and 1 fixed (257954 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Mar 9, 2023
@lcnr lcnr 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 Mar 10, 2023
@Dylan-DPC
Copy link
Member

closing this as it was a perf experiment

@Dylan-DPC Dylan-DPC closed this Aug 7, 2023
@Dylan-DPC Dylan-DPC added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants