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

dropck_outlives check whether generator witness needs_drop #117134

Merged
merged 4 commits into from
Nov 3, 2023

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Oct 24, 2023

see https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/.23116242.3A.20Code.20no.20longer.20compiles.20after.20-Zdrop-tracking-mir.20.E2.80.A6/near/398311627 for an explanation.

Fixes #116242 (or well, the repro by @jamuraa in #116242 (comment)). I did not add a regression test as it depends on other crates. We do have 1 test going from fail to pass, showing the intended behavior.

r? types

@lcnr lcnr added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 24, 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 Oct 24, 2023
@lcnr lcnr force-pushed the dropck_outlives-coroutine branch from cb8123f to 063cca2 Compare October 24, 2023 17:24
@lcnr lcnr added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Oct 24, 2023
@lcnr lcnr force-pushed the dropck_outlives-coroutine branch from 063cca2 to 2ca4c7e Compare October 24, 2023 17:26
@lcnr
Copy link
Contributor Author

lcnr commented Oct 24, 2023

@bors try

@bors
Copy link
Contributor

bors commented Oct 24, 2023

⌛ Trying commit 2ca4c7e with merge 2cf1c2a...

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 24, 2023
dropck_outlives check whether generator witness needs_drop

see https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/.23116242.3A.20Code.20no.20longer.20compiles.20after.20-Zdrop-tracking-mir.20.E2.80.A6/near/398311627 for an explanation.

Fixes rust-lang#116242 (or well, the repro by `@jamuraa` in rust-lang#116242 (comment)). I did not add a regression test as it depends on other crates. We do have 1 test going from fail to pass, showing the intended behavior.

r? types
// need to be dropped, and only require the captured types to be live
// if they do.
ty::Coroutine(_, args, _) => {
if self.reveal_coroutine_witnesses {
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 necessary to handle nested futures 🤔 should potentially add a test for it, but I don't feel motivated enough to do so 😅

@lcnr
Copy link
Contributor Author

lcnr commented Oct 24, 2023

want to run both crater and perf. Worried that I messed up and we get some weird cycles because of this, I am fairly confident that this is alright.

@bors
Copy link
Contributor

bors commented Oct 24, 2023

☀️ Try build successful - checks-actions
Build commit: 2cf1c2a (2cf1c2a614d6ae3bd50a8df20aeac2f9eceeea87)

@cjgillot
Copy link
Contributor

Thanks for figuring this out @lcnr!

@lcnr
Copy link
Contributor Author

lcnr commented Oct 26, 2023

@rust-timer queue

@craterbot check

@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 Oct 26, 2023
@craterbot
Copy link
Collaborator

👌 Experiment pr-117134 created and queued.
🤖 Automatically detected try build 2cf1c2a
🔍 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. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 26, 2023
@lcnr lcnr removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 26, 2023
@lcnr
Copy link
Contributor Author

lcnr commented Oct 26, 2023

assuming that the crater run and perf is acceptable, and to make sure we backport in time:

To quickly summarize again: the change from this PR is in bold

  • dropping a coroutine witness drops the values stored in its state machine: the content of its CoroutineWitness
  • computing the CoroutineWitness relies on mir_built
  • mir_built relies on fn needs_drop, we conservatively assume that all generators have to be dropped
  • we do not know the exact lifetimes of the values stored in the witness (as they may be self-referential), so for a coroutine to be drop live during mir_borrowck we require anything that could theoretically be accessed by the coroutine to be live.
  • however, during mir_borrowck we can access the CoroutineWitness, so we only require everything to be live if the coroutine actually contains any field which requires drop. This recursively looks into nested coroutines.

I believe that this does not result in query cycles as the only way needs_drop can access nested coroutines if they are from the same body. Coroutines from other bodies are hidden by an opaque type, which we should not be able to reveal.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Oct 26, 2023

Team member @lcnr has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 26, 2023
@lcnr
Copy link
Contributor Author

lcnr commented Oct 26, 2023

@craterbot p=1

@craterbot
Copy link
Collaborator

📝 Configuration of the pr-117134 experiment changed.

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

@lqd
Copy link
Member

lqd commented Oct 26, 2023

@rust-timer build 2cf1c2a

@rust-timer

This comment has been minimized.

@lcnr lcnr force-pushed the dropck_outlives-coroutine branch from 41a674e to dda5e32 Compare November 2, 2023 17:16
@lcnr
Copy link
Contributor Author

lcnr commented Nov 2, 2023

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Nov 2, 2023

📌 Commit dda5e32 has been approved by compiler-errors

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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2023
@bors
Copy link
Contributor

bors commented Nov 2, 2023

⌛ Testing commit dda5e32 with merge a2f5f96...

@bors
Copy link
Contributor

bors commented Nov 3, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing a2f5f96 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 3, 2023
@bors bors merged commit a2f5f96 into rust-lang:master Nov 3, 2023
11 checks passed
@rustbot rustbot added this to the 1.75.0 milestone Nov 3, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a2f5f96): 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)
0.3% [0.2%, 0.3%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.3%] 5

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

Binary size

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

Bootstrap: 636.864s -> 635.107s (-0.28%)
Artifact size: 304.51 MiB -> 304.48 MiB (-0.01%)

bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request Nov 3, 2023
82: Automated pull from upstream `master` r=tshepang a=github-actions[bot]


This PR pulls the following changes from the upstream repository:

* rust-lang/rust#117313
* rust-lang/rust#117131
* rust-lang/rust#117134
* rust-lang/rust#117471
* rust-lang/rust#117521
* rust-lang/rust#117513
  * rust-lang/rust#117512
  * rust-lang/rust#117509
  * rust-lang/rust#117495
  * rust-lang/rust#117394
* rust-lang/rust#117466
* rust-lang/rust#117204
* rust-lang/rust#117386
* rust-lang/rust#117506



Co-authored-by: Nicholas Nethercote <n.nethercote@gmail.com>
Co-authored-by: roblabla <unfiltered@roblab.la>
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: massivebird <gdrakemail@gmail.com>
Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: Zalathar <Zalathar@users.noreply.github.com>
Co-authored-by: lcnr <rust@lcnr.de>
Co-authored-by: Joshua Liebow-Feeser <joshlf@users.noreply.github.com>
Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
@lcnr lcnr added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 3, 2023
@lcnr lcnr deleted the dropck_outlives-coroutine branch November 3, 2023 09:28
@pnkfelix
Copy link
Member

pnkfelix commented Nov 7, 2023

  • regressed ripgrep check for incr-patched:println (0.35%), incr-full (0.26%), and full (0.21%); regressed regex check for incr-patched:Job (0.29%) and incr-patched:println (0.24%).
  • this is easily justified; it is fixing a code-acceptance regression
  • marking as triaged

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 7, 2023
@wesleywiser wesleywiser added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Nov 8, 2023
@wesleywiser
Copy link
Member

Accepting for beta backport as discussed during a previous compiler team triage meeting.

@cuviper cuviper mentioned this pull request Nov 9, 2023
@cuviper cuviper modified the milestones: 1.75.0, 1.74.0 Nov 9, 2023
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 9, 2023
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Nov 9, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 9, 2023
[beta] backports

- dropck_outlives check whether generator witness needs_drop rust-lang#117134
- Make sure that predicates with unmentioned bound vars are still considered global in the old solver rust-lang#117589
- Check binders with bound vars for global bounds that don't hold rust-lang#117637
- generator layout: ignore fake borrows rust-lang#117712

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2023
[beta] backports

- dropck_outlives check whether generator witness needs_drop rust-lang#117134
- Make sure that predicates with unmentioned bound vars are still considered global in the old solver rust-lang#117589
- Check binders with bound vars for global bounds that don't hold rust-lang#117637
- generator layout: ignore fake borrows rust-lang#117712

r? ghost
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code no longer compiles after -Zdrop-tracking-mir was enabled by default