2

Check `const Drop` impls considering `~const` Bounds by compiler-errors · Pull R...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/93028
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Copy link

Contributor

compiler-errors commented 12 days ago

edited

This PR adds logic to trait selection to account for ~const bounds in custom impl const Drop for types, elaborates the const Drop check in rustc_const_eval to check those bounds, and steals some drop linting fixes from #92922, thanks @DrMeepster.

r? @fee1-dead @oli-obk (edit: guess I can't request review from two people, lol)
since each of you wrote and reviewed #88558, respectively.

Since the logic here is more complicated than what existed, it's possible that this is a perf regression. But it works correctly with tests, and that makes me happy.

Fixes #92881

Copy link

Member

@fee1-dead fee1-dead left a comment •

edited

On a first glance the changes LGTM.

Preferably we'd want to have some sort of wf check for impl const Drops that requires it to already satisfy the conditions for a structurally const Drop, I'm not saying that it should be in this PR though.

I'll take a deeper look when I have time.

compiler-errors reacted with thumbs up emoji

Copy link

Contributor

oli-obk commented 11 days ago

Copy link

Collaborator

rust-timer commented 11 days ago

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

Copy link

Contributor

bors commented 11 days ago

hourglass Trying commit 33e5efb with merge 393a3fc...

Copy link

Contributor

bors commented 11 days ago

sunny Try build successful - checks-actions
Build commit: 393a3fc (393a3fc1041abc8da9d58b1bded5f9319123be5a)

Copy link

Collaborator

rust-timer commented 11 days ago

Copy link

Collaborator

rust-timer commented 11 days ago

Finished benchmarking commit (393a3fc): comparison url.

Summary: This change led to large relevant regressions crying_cat_face in compiler performance.

  • Large regression in instruction counts (up to 2.3% on full builds of keccak check)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

Copy link

Member

@fee1-dead fee1-dead left a comment

I think I understand what is causing this regression: For user-defined types, you want to select bounds on impl const Drops of the types and check if all bounds are satisfied. Instead of nesting a lot of obligations and running the trait selection process many times, why not extract the components to check bounds for and do just that? For types that require the environment (parameter types) and types that are user-defined, collect them into a list and test them. For other trivial components don't even nest obligations for them.

| ty::Bound(..)

| ty::Param(_)

| ty::Placeholder(_)

| ty::Never

This should be trivial to make Result<u8, !>: ~const Drop.

compiler-errors reacted with thumbs up emoji

Copy link

Contributor

Author

compiler-errors commented 11 days ago

edited

Instead of nesting a lot of obligations and running the trait selection process many times, why not extract the components to check bounds for and do just that?

I'm hesitant to structurally recurse on the type during candidate assembly (like the code was doing previously) because of normalization, and because other traits (e.g. auto traits, and Copy/Clone) leave that complicated machinery until during confirmation. I could perhaps be a bit more efficient with the list of nested obligations we generate during confirmation by directly recursing in cases like [Ty] => Ty, but I want to leave the code simpler if possible.

Actually I think the regression might've gone away with the last commit I pushed, at least with local testing on the keccak example...
@fee1-dead: Do you mind retrying a perf run? I'll see what I can do to make confirmation a bit more efficient if perf still says this code still needs some work.

Also I'll put up a fix to make !: ~const Drop later, but if you can get that perf run started I can check on it later.

Copy link

Collaborator

rust-timer commented 11 days ago

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

Copy link

Contributor

bors commented 11 days ago

hourglass Trying commit ba87be0 with merge b27084a...

Copy link

Contributor

bors commented 11 days ago

sunny Try build successful - checks-actions
Build commit: b27084a (b27084a23c48a70efdfbe79d73610550c8326204)

Copy link

Collaborator

rust-timer commented 11 days ago

Copy link

Collaborator

rust-timer commented 11 days ago

Finished benchmarking commit (b27084a): comparison url.

Summary: This change led to large relevant regressions crying_cat_face in compiler performance.

  • Large regression in instruction counts (up to 2.3% on full builds of keccak check)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

Copy link

Contributor

Author

compiler-errors commented 11 days ago

I'll look into this, I guess.

@rustbot author

Copy link

Contributor

bors commented 7 days ago

hourglass Testing commit b7e4433 with merge a63e682...

Copy link

Contributor

bors commented 7 days ago

broken_heart Test failed - checks-actions

Copy link

Collaborator

rust-log-analyzer commented 7 days ago

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Copy link

Contributor

Author

compiler-errors commented 6 days ago

Bors seems to have failed for exactly no reason... let's try this again? Wonder if that delegate gives me retry permissions..

@bors retry

Copy link

Contributor

bors commented 6 days ago

hourglass Testing commit b7e4433 with merge 9b1c49d...

Copy link

Contributor

bors commented 6 days ago

boom Test timed out

Copy link

Contributor

Author

compiler-errors commented 6 days ago

@bors retry because installing awscli timed out (x86_64-msvc-1)

Copy link

Collaborator

rust-log-analyzer commented 6 days ago

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Copy link

Contributor

Author

compiler-errors commented 6 days ago

I'll try this one more time before posting on zulip or something

@bors retry spurious failure with no reason provided

Copy link

Contributor

bors commented 6 days ago

hourglass Testing commit b7e4433 with merge ef119d7...

Copy link

Contributor

bors commented 5 days ago

sunny Test successful - checks-actions
Approved by: fee1-dead
Pushing ef119d7 to master...

Copy link

Collaborator

rust-timer commented 5 days ago

Finished benchmarking commit (ef119d7): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Milestone

1.60.0

Linked issues

Successfully merging this pull request may close these issues.

9 participants

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK