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

Use index based drop loop for slices and arrays #109085

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Mar 13, 2023

Instead of building two kinds of drop pair loops, of which only one will be eventually used at runtime in a given monomorphization, always use index based loop.

@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 13, 2023
@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 13, 2023

@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 13, 2023
@bors
Copy link
Contributor

bors commented Mar 13, 2023

⌛ Trying commit 5e5d676de9ddf29daa6b3f3f35fb3a3b84d32473 with merge 4ab473db23ab00fd0f20e0d2e533fff23afed969...

@bors
Copy link
Contributor

bors commented Mar 13, 2023

☀️ Try build successful - checks-actions
Build commit: 4ab473db23ab00fd0f20e0d2e533fff23afed969 (4ab473db23ab00fd0f20e0d2e533fff23afed969)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4ab473db23ab00fd0f20e0d2e533fff23afed969): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

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-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.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
0.6% [0.4%, 0.7%] 2
Improvements ✅
(primary)
-0.6% [-0.7%, -0.5%] 4
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.3%] 7
All ❌✅ (primary) -0.5% [-0.7%, 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)
- - 0
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
-3.8% [-5.3%, -2.8%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.8% [-5.3%, -2.8%] 3

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.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-0.8%, -0.8%] 1

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 14, 2023
Instead of building two kinds of drop pair loops, of which only one will
be eventually used at runtime in a given monomorphization, always use
index based loop.
@tmiasko tmiasko changed the title experiment: Always use index based drop loop for slices and arrays Use index based drop loop for slices and arrays Mar 15, 2023
@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 15, 2023

The pointer based variant was present in the first MIR implementation, but it
doesn't seem to lead to any optimization opportunities. For simplicity of the
implementation, and to avoid generating code for both variants, this proposes
to keep only index based variant.

r? compiler

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

For reference, I've reproduced index/pointer based drop impls for arrays and they seem to produce exactly the same assembly: https://godbolt.org/z/T89evrqK6

@WaffleLapkin
Copy link
Member

The perf looks mostly like noise, codegen behaves a bit differently with different input, maybe.

@WaffleLapkin WaffleLapkin added the perf-regression-triaged The performance regression has been triaged. label Mar 15, 2023
@WaffleLapkin
Copy link
Member

r? @WaffleLapkin
@bors r+

@bors
Copy link
Contributor

bors commented Mar 15, 2023

📌 Commit cf0e78b has been approved by WaffleLapkin

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 15, 2023
@bors
Copy link
Contributor

bors commented Mar 17, 2023

⌛ Testing commit cf0e78b with merge 2d64f22...

@bors
Copy link
Contributor

bors commented Mar 17, 2023

☀️ Test successful - checks-actions
Approved by: WaffleLapkin
Pushing 2d64f22 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 17, 2023
@bors bors merged commit 2d64f22 into rust-lang:master Mar 17, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 17, 2023
@tmiasko tmiasko deleted the index-based branch March 17, 2023 16:52
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2d64f22): comparison URL.

Overall result: ❌✅ regressions and 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.9% [0.9%, 0.9%] 1
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

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)
1.1% [0.1%, 2.6%] 4
Regressions ❌
(secondary)
3.2% [3.2%, 3.2%] 1
Improvements ✅
(primary)
-2.7% [-6.4%, -0.5%] 3
Improvements ✅
(secondary)
-2.8% [-2.8%, -2.8%] 1
All ❌✅ (primary) -0.5% [-6.4%, 2.6%] 7

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

@rustbot rustbot removed the perf-regression Performance regression. label Mar 17, 2023
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. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants