Skip to content

CopyProp: Propagate moves of constants#120689

Closed
clubby789 wants to merge 2 commits into
rust-lang:masterfrom
clubby789:copy-prop-consts
Closed

CopyProp: Propagate moves of constants#120689
clubby789 wants to merge 2 commits into
rust-lang:masterfrom
clubby789:copy-prop-consts

Conversation

@clubby789

Copy link
Copy Markdown
Contributor

Yet another try of #120650 - this time, keep track of SSA locals with a constant value and propagate it. Then, re-run SimplifyConstCondition to take advantage of it (simply reordering the pass regressed some tests).

r? @ghost

@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 Feb 5, 2024
@clubby789

Copy link
Copy Markdown
Contributor Author

@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 Feb 5, 2024
@bors

bors commented Feb 5, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 18f27f4 with merge 25ba6e3...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 5, 2024
CopyProp: Propagate moves of constants

Yet another try of rust-lang#120650 - this time, keep track of SSA locals with a constant value and propagate it. Then, re-run `SimplifyConstCondition` to take advantage of it (simply reordering the pass regressed some tests).

r? `@ghost`
@cjgillot

cjgillot commented Feb 5, 2024

Copy link
Copy Markdown
Contributor

I suggest you take a look at the discussion about determinism of MIR constants in gvn.rs. There are case where the same MIR constant will yield a different value each time it is evaluated.
Meanwhile, I take from this PR:

  • we could have a better ordering of passes;
  • we may be able to mark more constants as deterministic, for instance if they have integer type.

@bors

bors commented Feb 6, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 25ba6e3 (25ba6e3cb867376959985fb0cad7a13bec6530eb)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (25ba6e3): 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.4% [0.4%, 0.4%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-1.3%, -0.3%] 4
Improvements ✅
(secondary)
-0.6% [-1.1%, -0.2%] 2
All ❌✅ (primary) -0.4% [-1.3%, 0.4%] 6

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.9% [0.2%, 13.3%] 6
Regressions ❌
(secondary)
4.3% [0.8%, 7.2%] 7
Improvements ✅
(primary)
-5.2% [-7.6%, -2.8%] 2
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) 3.1% [-7.6%, 13.3%] 8

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

Binary size

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.2% [0.0%, 0.4%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.6%, -0.0%] 42
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-0.6%, 0.4%] 47

Bootstrap: 660.166s -> 663.073s (0.44%)
Artifact size: 308.14 MiB -> 308.13 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 6, 2024
@clubby789

Copy link
Copy Markdown
Contributor Author

Removed the pass ordering part. If perf looks happier, perhaps we can use this to simplify #120650 - rather than needing to codegen_operand, we can just check if our discrim is a const scalar.

@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 Feb 6, 2024
@bors

bors commented Feb 6, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 7a6abd5 with merge 22f542c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2024
CopyProp: Propagate moves of constants

Yet another try of rust-lang#120650 - this time, keep track of SSA locals with a constant value and propagate it. Then, re-run `SimplifyConstCondition` to take advantage of it (simply reordering the pass regressed some tests).

r? `@ghost`
@bors

bors commented Feb 7, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 22f542c (22f542c3e4b78858e75d4296f49b7aa6134122a9)

1 similar comment
@bors

bors commented Feb 7, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 22f542c (22f542c3e4b78858e75d4296f49b7aa6134122a9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (22f542c): comparison URL.

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

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)
3.7% [0.3%, 6.6%] 5
Regressions ❌
(secondary)
3.9% [3.9%, 3.9%] 1
Improvements ✅
(primary)
-3.2% [-6.0%, -1.4%] 4
Improvements ✅
(secondary)
-10.2% [-10.2%, -10.2%] 1
All ❌✅ (primary) 0.7% [-6.0%, 6.6%] 9

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

Binary size

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.2% [0.0%, 0.4%] 11
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.3%, -0.1%] 15
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.3%, 0.4%] 26

Bootstrap: 663.272s -> 663.514s (0.04%)
Artifact size: 308.23 MiB -> 308.20 MiB (-0.01%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Feb 7, 2024
@clubby789

Copy link
Copy Markdown
Contributor Author

Small net improvements if I run perf locally, so I think just noise

@clubby789

clubby789 commented Feb 10, 2024

Copy link
Copy Markdown
Contributor Author

It looks like the previous slight improvements to MIR in tests were also done by #120594. That said, this seems to be basically perf-neutral and a bit more general so may be worth having.

r? compiler

@clubby789 clubby789 marked this pull request as ready for review February 10, 2024 23:32
@rustbot

rustbot commented Feb 10, 2024

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

let (Rvalue::Use(Operand::Copy(place) | Operand::Move(place))
| Rvalue::CopyForDeref(place)) = rvalue
else {
let (Rvalue::Use(Operand::Copy(place)) | Rvalue::CopyForDeref(place)) = rvalue else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given that the Operand::Move case does nothing (due to the check below), we can remove that here and remove the duplicated check below

@compiler-errors

Copy link
Copy Markdown
Contributor

r? cjgillot

@rustbot rustbot assigned cjgillot and unassigned compiler-errors Feb 12, 2024
@cjgillot

Copy link
Copy Markdown
Contributor

From the results of the #120650 (comment), do we still need this PR? Or should we merge #120650 on its own?

@cjgillot cjgillot 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 Feb 18, 2024
@clubby789

Copy link
Copy Markdown
Contributor Author

First lets see if this still has any perf impact:

@bors try @rust-timer queue

I suspect not - if this comes up neutral I'll probably close

@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 Apr 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
CopyProp: Propagate moves of constants

Yet another try of rust-lang#120650 - this time, keep track of SSA locals with a constant value and propagate it. Then, re-run `SimplifyConstCondition` to take advantage of it (simply reordering the pass regressed some tests).

r? `@ghost`
@bors

bors commented Apr 16, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit cf02fa9 with merge 1515cb7...

@bors

bors commented Apr 16, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 1515cb7 (1515cb760c8a0555b9712621f65c11a283b0eaf4)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1515cb7): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

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)
3.8% [2.5%, 5.0%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.3% [-2.1%, 5.0%] 4

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

Binary size

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.1% [0.0%, 0.5%] 9
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.4%, -0.0%] 7
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.4%, 0.5%] 16

Bootstrap: 678.471s -> 677.873s (-0.09%)
Artifact size: 316.03 MiB -> 315.98 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 16, 2024
@clubby789 clubby789 closed this Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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