[WIP] mir-opt: promoting const read-only arrays by tesuji · Pull Request #125916 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation33 Commits17 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Modified from a copy of PromoteTemps. It's kind of a hack so nothing fancy or easy to follow and review.
I'll to reuse structures from PromoteTemps when there is consensus for this pass.
Compiler is doing more work now with this opt. So I don't think this pass improves compiler performance.
But anyway, for statistics, can I get a perf run?
cc #73825
r? ghost
Current status
- Waiting for consensus.
- Maybe rewrite to use GVN with mentor from oli
ICE on unstable feature: tests/assembly/simd-intrinsic-mask-load.rs#x86-avx512.
In particularSimd([literal array])
now transformed toSimd(array_var)
. Maybe I should ignore array in constructor.Fail test on nested arrays
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.
labels
Some changes occurred to MIR optimizations
cc @rust-lang/wg-mir-opt
This comment has been minimized.
bors added a commit to rust-lang-ci/rust that referenced this pull request
This comment has been minimized.
This comment has been minimized.
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
&[&promote_pass, &simplify::SimplifyCfg::PromoteConsts, &coverage::InstrumentCoverage], |
---|
&[ |
&promote_pass, |
&promote_array, |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is something that should not have user-visible effects (e.g. affecting dropck, const eval UB or borrowck), it should be run as part of the regular runtime optimization pipeline
Comment on lines +370 to +361
let array_promoted = promote_array.promoted_fragments.into_inner(); |
---|
promoted.extend(array_promoted); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which does mean you won't be able to use the existing promotion scheme, but would need to start looking into create_def
and query feeding, which is probably not ready to support this use case yet. I have not yet given it much thought what is needed to fully support that, but if you want we can look into this together.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then again, if all we're doing is creating non-generic static items, that already has precedent (we do that for nested statics), so likely you can do the same in an optimization.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though in that case I would expect this to fall out of GVN or some similar optimization, not be its own separate path
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With GVN or similar you don't even need to create new constants and MIR bodies, you can just stick the fully evaluated constant into a MIR constant
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors added a commit to rust-lang-ci/rust that referenced this pull request
…=
[WIP] mir-opt: promoting const read-only arrays
Modified from a copy of PromoteTemps. It's kind of a hack so nothing fancy or easy to follow and review. I'll to reuse structures from PromoteTemps when there is consensus for this pass.
Compiler is doing more work now with this opt. So I don't think this pass improves compiler performance. But anyway, for statistics, can I get a perf run?
r? ghost
Current status
- Waiting for consensus.
- Fail simd tests: tests/assembly/simd-intrinsic-mask-load.rs#x86-avx512
Fail test on nested arrays: hack fix, may possibly fail on struct containings arrays.- Maybe rewrite to [use GVN with mentor from oli][mentor]
[mentor]: rust-lang#125916 (comment)
This comment has been minimized.
☀️ Try build successful - checks-actions
Build commit: c415513 (c4155130fd61e7fa5e1b138de6a817f1cfb4e2fb
)
This comment has been minimized.
Finished benchmarking commit (c415513): 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.2%, 0.3%] | 13 |
Regressions ❌ (secondary) | 0.6% | [0.5%, 0.7%] | 9 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | -0.1% | [-0.1%, -0.1%] | 1 |
All ❌✅ (primary) | 0.3% | [0.2%, 0.3%] | 13 |
Max RSS (memory usage)
Results (primary -5.8%, secondary -2.2%)
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) | -5.8% | [-5.8%, -5.8%] | 1 |
Improvements ✅ (secondary) | -2.2% | [-2.2%, -2.2%] | 1 |
All ❌✅ (primary) | -5.8% | [-5.8%, -5.8%] | 1 |
Cycles
This benchmark run did not return any relevant results for this metric.
Binary size
Results (primary 0.0%)
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.0% | [0.0%, 0.0%] | 8 |
Regressions ❌ (secondary) | - | - | 0 |
Improvements ✅ (primary) | -0.0% | [-0.0%, -0.0%] | 1 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | 0.0% | [-0.0%, 0.0%] | 9 |
Bootstrap: 673.596s -> 672.754s (-0.13%)
Artifact size: 318.88 MiB -> 318.85 MiB (-0.01%)
For the SIMD mention: the long-term goal is to stop allowing projections into repr(simd)
types at all, just Transmute
. So whatever fix is easiest is fine, as that situation will stop happening hopefully-soon.
This comment has been minimized.
Can I get another perf run before switching to use GVN?
This comment has been minimized.
bors added a commit to rust-lang-ci/rust that referenced this pull request
…=
[WIP] mir-opt: promoting const read-only arrays
Modified from a copy of PromoteTemps. It's kind of a hack so nothing fancy or easy to follow and review. I'll to reuse structures from PromoteTemps when there is consensus for this pass.
Compiler is doing more work now with this opt. So I don't think this pass improves compiler performance. But anyway, for statistics, can I get a perf run?
r? ghost
Current status
- Waiting for consensus.
- Maybe rewrite to [use GVN with mentor from oli][mentor]
-
ICE on unstable feature: tests/assembly/simd-intrinsic-mask-load.rs#x86-avx512.In particularSimd([literal array])
now transformed toSimd(array_var)
. Maybe I should ignore array in constructor. -
Fail test on nested arrays
[mentor]: rust-lang#125916 (comment)
☀️ Try build successful - checks-actions
Build commit: 63ac52a (63ac52aeb8179ad1a9d0a60cc0cf82812d3ddb65
)
This comment has been minimized.
Finished benchmarking commit (63ac52a): comparison URL.
Overall result: ❌ regressions - 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.2%, 0.3%] | 17 |
Regressions ❌ (secondary) | 0.1% | [0.1%, 0.1%] | 3 |
Improvements ✅ (primary) | - | - | 0 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | 0.3% | [0.2%, 0.3%] | 17 |
Max RSS (memory usage)
Results (primary -8.1%)
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) | -8.1% | [-8.1%, -8.1%] | 1 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | -8.1% | [-8.1%, -8.1%] | 1 |
Cycles
This benchmark run did not return any relevant results for this metric.
Binary size
Results (primary -0.0%)
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.0% | [-0.0%, -0.0%] | 1 |
Improvements ✅ (secondary) | - | - | 0 |
All ❌✅ (primary) | -0.0% | [-0.0%, -0.0%] | 1 |
Bootstrap: 673.707s -> 672.398s (-0.19%)
Artifact size: 319.82 MiB -> 319.84 MiB (0.01%)
This was referenced
Jun 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request
Closing in favor of #126444.
But there may have clean-up commits for PromoteTemps.
bors added a commit to rust-lang-ci/rust that referenced this pull request
tesuji deleted the mir-opt-const-array-locals branch
bors added a commit to rust-lang-ci/rust that referenced this pull request
promote_consts: some clean-up after experimenting
This is some clean-up after experimenting in rust-lang#125916, Prefer to review commit-by-commit.
bors added a commit to rust-lang-ci/rust that referenced this pull request
bors added a commit to rust-lang-ci/rust that referenced this pull request