Skip to content

Drop array patterns using subslices #109008

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

Merged
merged 1 commit into from
Apr 2, 2023

Conversation

clubby789
Copy link
Contributor

@clubby789 clubby789 commented Mar 10, 2023

Fixes #109004
Drops contiguous subslices of an array when moving elements out with a pattern, which improves perf for large arrays
r? @compiler-errors

@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 Mar 10, 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 10, 2023
@bors
Copy link
Collaborator

bors commented Mar 10, 2023

⌛ Trying commit fb7275c5f1fd470a7bb97cbac0a71224b280fad7 with merge f6318045f80c3b6b7cee0b1c420dd1a84ce61091...

@compiler-errors
Copy link
Member

Also this will eventually need a UI test :)

@bors
Copy link
Collaborator

bors commented Mar 11, 2023

💔 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 Mar 11, 2023
@clubby789 clubby789 force-pushed the drop-elaborate-array branch from fb7275c to f9e457f Compare March 11, 2023 00:23
@clubby789 clubby789 changed the title Treat arrays and slices the same for drop elaboration Don't eagerly make array projections during drop elaboration Mar 11, 2023
@compiler-errors
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 11, 2023

⌛ Trying commit f9e457ff59cdd3daef958fcac7e0dfefb3eb3051 with merge 8633c7b8d24f7723cc99e11b7a9707871935a2b6...

@bors
Copy link
Collaborator

bors commented Mar 11, 2023

☀️ Try build successful - checks-actions
Build commit: 8633c7b8d24f7723cc99e11b7a9707871935a2b6 (8633c7b8d24f7723cc99e11b7a9707871935a2b6)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8633c7b8d24f7723cc99e11b7a9707871935a2b6): comparison URL.

Overall result: ✅ improvements - no 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.

@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
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 2

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)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.2%, -0.9%] 2
All ❌✅ (primary) - - 0

Cycles

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2023
@clubby789
Copy link
Contributor Author

This now fixes the case from the example, but still blows up memory when the huge array is partially moved from.

@compiler-errors
Copy link
Member

I'm happy to r+ this with a detailed comment, both explaining what the double iteration is doing and where it falls short, and a UI test.

@clubby789 clubby789 force-pushed the drop-elaborate-array branch from f9e457f to 8c74c5e Compare March 11, 2023 21:07
@clubby789
Copy link
Contributor Author

Added a test and explanation, but I'll try and investigate a better solution for this

@rust-log-analyzer

This comment has been minimized.

@clubby789
Copy link
Contributor Author

clubby789 commented Mar 12, 2023

Found a new approach that seems to work, passing relevant drop tests locally and fixes both dropping large arrays and moving out of them.

  1. Iterate over array_subpath for each index, recording contiguous ranges where array_subpath is None
  2. For any indexes which are Some, push the current range, then path and then start a new range
  3. Iterate backward over the ranges - for a Drop, make a place for the subslice and for a Keep make a place for the index
  4. Pass these places and paths to the drop ladder as before

I'll squash + update PR desc if this looks good

@rustbot ready

@bors
Copy link
Collaborator

bors commented Mar 31, 2023

📌 Commit ce2d528 has been approved by davidtwco

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 Mar 31, 2023
@bors
Copy link
Collaborator

bors commented Mar 31, 2023

⌛ Testing commit ce2d528 with merge f71b58d5b418fbf1b5156d833b464bb60470d38b...

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Finished release [optimized] target(s) in 12.39s
[TIMING] check::CodegenBackend { target: i686-pc-windows-gnu, backend: "cranelift" } -- 12.403
Checking stage0 gcc library (x86_64-unknown-linux-gnu -> i686-pc-windows-gnu)
    Updating git repository `https://github.com/antoyo/gccjit.rs`
warning: spurious network error (2 tries remaining): failed to connect to github.com: Connection refused; class=Os (2)
warning: spurious network error (1 tries remaining): failed to connect to github.com: Connection refused; class=Os (2)
error: failed to get `gccjit` as a dependency of package `rustc_codegen_gcc v0.1.0 (/checkout/compiler/rustc_codegen_gcc)`
Caused by:
Caused by:
  failed to load source for dependency `gccjit`
Caused by:
  Unable to update https://github.com/antoyo/gccjit.rs#fe242b7e

Caused by:
Caused by:
  failed to clone into: /cargo/git/db/gccjit.rs-13c2e290f2fb9e4d
Caused by:
  failed to connect to github.com: Connection refused; class=Os (2)
Build completed unsuccessfully in 0:01:39

@bors
Copy link
Collaborator

bors commented Mar 31, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 31, 2023
@cjgillot
Copy link
Contributor

cjgillot commented Apr 1, 2023

@bors retry failed to connect to github.com

@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 Apr 1, 2023
@bors
Copy link
Collaborator

bors commented Apr 1, 2023

⌛ Testing commit ce2d528 with merge 9482c66f424c8c22af3c6dab3afa7af5fd870e44...

@rust-log-analyzer
Copy link
Collaborator

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

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

@bors
Copy link
Collaborator

bors commented Apr 1, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 1, 2023
@cjgillot
Copy link
Contributor

cjgillot commented Apr 2, 2023

@bors retry failed during checkout

@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 Apr 2, 2023
@bors
Copy link
Collaborator

bors commented Apr 2, 2023

⌛ Testing commit ce2d528 with merge a5a690c...

@bors
Copy link
Collaborator

bors commented Apr 2, 2023

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing a5a690c to master...

1 similar comment
@bors
Copy link
Collaborator

bors commented Apr 2, 2023

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing a5a690c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 2, 2023
@bors bors merged commit a5a690c into rust-lang:master Apr 2, 2023
@rustbot rustbot added this to the 1.70.0 milestone Apr 2, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a5a690c): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 2

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)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.4%] 2
All ❌✅ (primary) - - 0

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)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) - - 0

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

Compiling drop(Box<large array>) causes runaway compiler memory usage
9 participants