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

Fix Deref args when #[const_trait] is enabled #118386

Closed
wants to merge 2 commits into from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 27, 2023

Fix Deref being a #[const_trait]. To fix this fully, we also need to pass the host param to method_autoderef_steps and make sure we use it correctly in Autoderef.

@compiler-errors
Copy link
Member Author

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 27, 2023
@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 Nov 27, 2023
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 28, 2023

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

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member Author

This code is still broken for two reasons:

  1. method_autoderef_steps doesn't know anything about the constness of the function, so it fails to select a Deref impl cause of ambiguity
  2. Projections have a host parameter but we don't currently know what to do with them...

@compiler-errors
Copy link
Member Author

This is ready :>

We just need to pass the host param to Autoderef and canonicalize it in method_autoderef_steps.

@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 Dec 18, 2023
@compiler-errors compiler-errors marked this pull request as ready for review December 18, 2023 20:19
@bors
Copy link
Contributor

bors commented Dec 18, 2023

⌛ Trying commit 38e0402 with merge 4a90a2c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2023
Fix `Deref` args when `#[const_trait]` is enabled

r? `@fee1-dead`

This is still pretty broken, but putting this PR up so I don't lose the code in some `git stash` somewhere...
@bors
Copy link
Contributor

bors commented Dec 18, 2023

☀️ Try build successful - checks-actions
Build commit: 4a90a2c (4a90a2c83dbb51ae7aa0f7efa5b3aba7cd165e4f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4a90a2c): comparison URL.

Overall result: ❌ regressions - 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.4% [0.1%, 0.7%] 38
Regressions ❌
(secondary)
0.5% [0.2%, 0.8%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.1%, 0.7%] 38

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

Cycles

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

Binary size

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

Bootstrap: 673.958s -> 673.623s (-0.05%)
Artifact size: 312.41 MiB -> 312.44 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 18, 2023
@compiler-errors
Copy link
Member Author

I feel like we just need to accept this perf regression 😅, since it's likely not possible to avoid needing to pass in the host param in method_autoderef_steps, and we're simply doing more work here. Happy to discuss this if anyone disagrees, though.

@compiler-errors compiler-errors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 19, 2023
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

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

sorry about the lack of response here, r=me after the two tiny nits

@compiler-errors
Copy link
Member Author

I'm curious about perf...

@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 Jan 8, 2024
@bors
Copy link
Contributor

bors commented Jan 8, 2024

⌛ Trying commit a453884 with merge 34aeaa2...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 8, 2024
Fix `Deref` args when `#[const_trait]` is enabled

Fix `Deref` being a `#[const_trait]`. To fix this fully, we also need to pass the host param to `method_autoderef_steps` and make sure we use it correctly in `Autoderef`.
@bors
Copy link
Contributor

bors commented Jan 8, 2024

☀️ Try build successful - checks-actions
Build commit: 34aeaa2 (34aeaa28971ceecb8ae34abcf0c3d6ab41e0a673)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (34aeaa2): comparison URL.

Overall result: ❌ regressions - 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.4% [0.2%, 0.7%] 40
Regressions ❌
(secondary)
0.4% [0.2%, 0.8%] 11
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.2%, 0.7%] 40

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.9% [0.9%, 0.9%] 1
Regressions ❌
(secondary)
10.5% [10.5%, 10.5%] 1
Improvements ✅
(primary)
-0.8% [-1.1%, -0.5%] 2
Improvements ✅
(secondary)
-1.9% [-2.5%, -1.3%] 3
All ❌✅ (primary) -0.2% [-1.1%, 0.9%] 3

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)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
-0.6% [-0.8%, -0.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.8%, -0.5%] 2

Binary size

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

Bootstrap: 667.831s -> 668.134s (0.05%)
Artifact size: 308.39 MiB -> 308.55 MiB (0.05%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 9, 2024
@fee1-dead
Copy link
Member

I think there may be potential optimizations related to caching behavior with the host generic params. Currently the trait system would probably cache non-const trait bounds and const trait bounds separately. If we find a way to mark which host args come from the original obligation carried forward, then we'd only need to select traits once (considering that concrete impls like impl const always implements both non-const and const, giving us a happy path).

I'm not entirely sure why we'd have this many regressions, though. expected_host_effect_param_for_body is only different if we are in a const fn, where there shouldn't be any deref (though we'd still have to check when typechecking method calls?) We might try to fix the regressions on stable code by checking the effects feature somewhere, and just passing in tcx.consts.true_ if we don't have effects enabled.

@fee1-dead
Copy link
Member

Well, hmm, it looks like expected_host_effect_param_for_body already forces the host the param to be true. Why would this have a regression then?

@compiler-errors
Copy link
Member Author

I think it may just be due to additional caching. I will test a few things, but otherwise I feel like we should absorb the perf hit since it seems inevitable.

@fee1-dead
Copy link
Member

feel free to r=me after you have done the testing

@fee1-dead fee1-dead added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. perf-regression Performance regression. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. perf-regression Performance regression. labels Jan 20, 2024
@compiler-errors
Copy link
Member Author

This is gonna have to be reworked after @fee1-dead adjusts the const trait desugaring, I think. Or otherwise, this can be revived later.

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-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.

6 participants