Skip to content

Drop array patterns using subslices - #109008

Merged
bors merged 1 commit into
rust-lang:masterfrom
clubby789:drop-elaborate-array
Apr 2, 2023
Merged

bors merged 1 commit into
rust-lang:masterfrom
clubby789:drop-elaborate-array

Conversation

@clubby789

@clubby789 clubby789 commented Mar 10, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

@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

bors commented Mar 10, 2023

Copy link
Copy Markdown
Collaborator

⌛ Trying commit fb7275c5f1fd470a7bb97cbac0a71224b280fad7 with merge f6318045f80c3b6b7cee0b1c420dd1a84ce61091...

@compiler-errors

Copy link
Copy Markdown
Contributor

Also this will eventually need a UI test :)

@bors

bors commented Mar 11, 2023

Copy link
Copy Markdown
Collaborator

💔 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
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors

bors commented Mar 11, 2023

Copy link
Copy Markdown
Collaborator

⌛ Trying commit f9e457ff59cdd3daef958fcac7e0dfefb3eb3051 with merge 8633c7b8d24f7723cc99e11b7a9707871935a2b6...

@bors

bors commented Mar 11, 2023

Copy link
Copy Markdown
Collaborator

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

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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

clubby789 commented Mar 12, 2023 •

Copy link
Copy Markdown
Contributor Author

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 bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 31, 2023
@bors

bors commented Mar 31, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit ce2d528 with merge f71b58d5b418fbf1b5156d833b464bb60470d38b...

@rust-log-analyzer

Copy link
Copy Markdown
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

bors commented Mar 31, 2023

Copy link
Copy Markdown
Collaborator

💔 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

cjgillot commented Apr 1, 2023

Copy link
Copy Markdown
Contributor

@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

bors commented Apr 1, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit ce2d528 with merge 9482c66f424c8c22af3c6dab3afa7af5fd870e44...

@rust-log-analyzer

Copy link
Copy Markdown
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

bors commented Apr 1, 2023

Copy link
Copy Markdown
Collaborator

💔 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

cjgillot commented Apr 2, 2023

Copy link
Copy Markdown
Contributor

@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

bors commented Apr 2, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit ce2d528 with merge a5a690c...

@bors

bors commented Apr 2, 2023

Copy link
Copy Markdown
Collaborator

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

1 similar comment
@bors

bors commented Apr 2, 2023

Copy link
Copy Markdown
Collaborator

☀️ 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
Copy Markdown
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