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

[experimental] Rvalue::InitBox prototype #88700

Closed
wants to merge 4 commits into from

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Sep 6, 2021

r? @ghost

@Amanieu
Copy link
Member

Amanieu commented Sep 6, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 6, 2021
@bors
Copy link
Contributor

bors commented Sep 6, 2021

⌛ Trying commit 1dbf96965414a4778e996dc03952b9d0c318e884 with merge b375876e20ce4a2eff0f9588c09aa4e4114f696a...

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 6, 2021

💔 Test failed - checks-actions

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 6, 2021
@nbdd0121
Copy link
Contributor Author

nbdd0121 commented Sep 6, 2021

Do I actually need to fix all tools before a perf run could be done 🤔

@Amanieu
Copy link
Member

Amanieu commented Sep 6, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@bors
Copy link
Contributor

bors commented Sep 6, 2021

⌛ Trying commit 50f13a3 with merge a7b586082fae51c336ba78f005a339965e537c85...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Sep 6, 2021

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

@rust-timer
Copy link
Collaborator

Queued a7b586082fae51c336ba78f005a339965e537c85 with parent 8ceea01, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a7b586082fae51c336ba78f005a339965e537c85): comparison url.

Summary: This change led to large relevant mixed results 🤷 in compiler performance.

  • Moderate improvement in instruction counts (up to -0.7% on incr-unchanged builds of html5ever)
  • Large regression in instruction counts (up to 10.6% on incr-patched: println builds of regression-31157)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 7, 2021
@rust-log-analyzer
Copy link
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)
    Checking cranelift-native v0.75.0 (https://github.com/bytecodealliance/wasmtime.git#5deda279)
    Checking cranelift-frontend v0.75.0 (https://github.com/bytecodealliance/wasmtime.git#5deda279)
    Checking cranelift-object v0.75.0 (https://github.com/bytecodealliance/wasmtime.git#5deda279)
    Checking rustc_codegen_cranelift v0.1.0 (/checkout/compiler/rustc_codegen_cranelift)
error[E0004]: non-exhaustive patterns: `InitBox(_, _)` not covered
     |
     |
459  |             match to_place_and_rval.1 {
     |                   ^^^^^^^^^^^^^^^^^^^ pattern `InitBox(_, _)` not covered
    ::: /checkout/compiler/rustc_middle/src/mir/mod.rs:2174:5
     |
     |
2174 |     InitBox(Operand<'tcx>, Ty<'tcx>),
     |
     = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
     = note: the matched value is of type `rustc_middle::mir::Rvalue`

@oli-obk
Copy link
Contributor

oli-obk commented Sep 7, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 7, 2021
@bors
Copy link
Contributor

bors commented Sep 7, 2021

⌛ Trying commit a9c6bfb with merge 29328d5b353b632549fa019564fbf8e9daf44703...

@bors
Copy link
Contributor

bors commented Sep 7, 2021

☀️ Try build successful - checks-actions
Build commit: 29328d5b353b632549fa019564fbf8e9daf44703 (29328d5b353b632549fa019564fbf8e9daf44703)

@rust-timer
Copy link
Collaborator

Queued 29328d5b353b632549fa019564fbf8e9daf44703 with parent 73641cd, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (29328d5b353b632549fa019564fbf8e9daf44703): comparison url.

Summary: This change led to large relevant mixed results 🤷 in compiler performance.

  • Large improvement in instruction counts (up to -2.5% on full builds of deeply-nested-async)
  • Moderate regression in instruction counts (up to 1.9% on incr-patched: println builds of syn)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led 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-review -S-waiting-on-perf +perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 7, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2021
Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of rust-lang#88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
@nbdd0121 nbdd0121 closed this Sep 16, 2021
@nbdd0121
Copy link
Contributor Author

Closed this PR as it's an experiment; #89030 is the ready version for merge.

bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Sep 19, 2021
Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of rust-lang#88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2021
Introduce `Rvalue::ShallowInitBox`

Polished version of rust-lang#88700.

Implements MCP rust-lang/compiler-team#460, and should allow rust-lang#43596 to go forward.

In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP.

`NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient.

Experiments in rust-lang#88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 28, 2021
Introduce NullOp::AlignOf

This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`.

The changes are originally part of rust-lang#88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
flip1995 pushed a commit to flip1995/rust that referenced this pull request Sep 28, 2021
Introduce `Rvalue::ShallowInitBox`

Polished version of rust-lang#88700.

Implements MCP rust-lang/compiler-team#460, and should allow rust-lang#43596 to go forward.

In short, creating an empty box is split from a nullary-op `NullOp::Box` into two steps, first a call to `exchange_malloc`, then a `Rvalue::ShallowInitBox` which transmutes `*mut u8` to a shallow-initialized `Box<T>`. This allows the `exchange_malloc` call to unwind. Details can be found in the MCP.

`NullOp::Box` is not yet removed, purely to make reverting easier in case anything goes wrong as the result of this PR. If revert is needed a reversion of "Use Rvalue::ShallowInitBox for box expression" commit followed by a test bless should be sufficient.

Experiments in rust-lang#88700 showed a very slight compile-time perf regression due to (supposedly) slightly more time spent in LLVM. We could omit unwind edge generation (in non-`oom=panic` case) in box expression MIR construction to restore perf; but I don't think it's necessary since runtime perf isn't affected and perf difference is rather small.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants