[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 }})

tesuji

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

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

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Jun 3, 2024

@rustbot

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@Urgau

@rust-timer

This comment has been minimized.

@bors

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 3, 2024

@bors

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors

@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

Jun 3, 2024

oli-obk

&[&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

oli-obk

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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lqd

@rust-timer

This comment has been minimized.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 4, 2024

@bors

…=

[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?

cc rust-lang#73825

r? ghost

Current status

[mentor]: rust-lang#125916 (comment)

@bors

@rust-log-analyzer

This comment has been minimized.

@bors

☀️ Try build successful - checks-actions
Build commit: c415513 (c4155130fd61e7fa5e1b138de6a817f1cfb4e2fb)

@rust-timer

This comment has been minimized.

@rust-timer

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%)

@scottmcm

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.

@rust-log-analyzer

This comment has been minimized.

@tesuji

Can I get another perf run before switching to use GVN?

@Kobzol

@rust-timer

This comment has been minimized.

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 10, 2024

@bors

…=

[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?

cc rust-lang#73825

r? ghost

Current status

[mentor]: rust-lang#125916 (comment)

@bors

@bors

☀️ Try build successful - checks-actions
Build commit: 63ac52a (63ac52aeb8179ad1a9d0a60cc0cf82812d3ddb65)

@rust-timer

This comment has been minimized.

@rust-timer

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

Jun 13, 2024

@bors

@tesuji

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

Jun 14, 2024

@bors

@tesuji tesuji deleted the mir-opt-const-array-locals branch

June 16, 2024 09:34

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 21, 2024

@bors

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

Jul 14, 2024

@bors

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jul 14, 2024

@bors