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

replace vec::Drain drop loops with drop_in_place #85157

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

the8472
Copy link
Member

@the8472 the8472 commented May 10, 2021

The Drain::drop implementation came up in #82185 (comment) as potentially interfering with other optimization work due its widespread use somewhere in println!

@rustbot label T-libs-impl

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 10, 2021
@rust-highfive
Copy link
Collaborator

r? @yaahc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 10, 2021
@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 10, 2021
@bors
Copy link
Contributor

bors commented May 10, 2021

⌛ Trying commit 5cd25a3c8de8ac50571849c91869d27b0aedf1b4 with merge f43378a4f09d5d51bfbc4bca4d5abbd28238f176...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 10, 2021

💔 Test failed - checks-actions

@bors bors 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 May 10, 2021
@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented May 10, 2021

⌛ Trying commit 032fa35 with merge 29e55f8f91bd74ab69933dd9166d41317e0146b7...

@bors
Copy link
Contributor

bors commented May 10, 2021

☀️ Try build successful - checks-actions
Build commit: 29e55f8f91bd74ab69933dd9166d41317e0146b7 (29e55f8f91bd74ab69933dd9166d41317e0146b7)

@rust-timer
Copy link
Collaborator

Queued 29e55f8f91bd74ab69933dd9166d41317e0146b7 with parent 6fd7a6d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (29e55f8f91bd74ab69933dd9166d41317e0146b7): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 11, 2021
@the8472
Copy link
Member Author

the8472 commented May 11, 2021

seems kind of mixed. @SkiFire13 do you think it would make sense to test your changes on top of these?

@SkiFire13
Copy link
Contributor

I might give it a try, give me a sec to rebase my pr on top of yours.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 31, 2021
@JohnTitor JohnTitor removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 15, 2021
@JohnCSimon
Copy link
Member

triage:
@yaahc This has been sitting in review state since may

@yaahc
Copy link
Member

yaahc commented Nov 15, 2021

triage: @yaahc This has been sitting in review state since may

Still on my radar, just haven't had a chance to review it yet.

@Mark-Simulacrum Mark-Simulacrum 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 Nov 20, 2021
@Mark-Simulacrum
Copy link
Member

@the8472 if you want to leave the cleanup of spare capacity to something simpler for the future, that seems OK to me as well I think.

@the8472 the8472 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 8, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 9, 2021

📌 Commit 2d8a11b has been approved by Mark-Simulacrum

@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 Dec 9, 2021
@bors
Copy link
Contributor

bors commented Dec 9, 2021

⌛ Testing commit 2d8a11b with merge 0b42dea...

@bors
Copy link
Contributor

bors commented Dec 9, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 0b42dea to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 9, 2021
@bors bors merged commit 0b42dea into rust-lang:master Dec 9, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 9, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0b42dea): comparison url.

Summary: This change led to large relevant improvements 🎉 in compiler performance.

  • Large improvement in instruction counts (up to -1.7% on full builds of match-stress-enum)

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

@rustbot label: -perf-regression

@the8472
Copy link
Member Author

the8472 commented Dec 9, 2021

Nice, better results than the previous perf run.

@RalfJung
Copy link
Member

Is it possible that this introduced a use-after-free?

mem::forget(guard);
let iter = mem::replace(&mut self.iter, (&mut []).iter());
let drop_len = iter.len();
let drop_ptr = iter.as_slice().as_ptr();
Copy link
Member

Choose a reason for hiding this comment

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

Specifically, Miri says that in this line as_slice points to dangling memory (in some cases, here triggered by the test_replace_range testcase)

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'm under the impression that the iter should be valid at all times, but I'll have a closer look at the test-case.

Copy link
Member

Choose a reason for hiding this comment

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

(Continuing in #91772)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.