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

[mir-opt] Turn on the ConstProp pass by default #66074

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

wesleywiser
Copy link
Member

@wesleywiser wesleywiser commented Nov 4, 2019

perf.rlo shows that running the ConstProp pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.

@wesleywiser
Copy link
Member Author

@bors try
@rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Nov 4, 2019

⌛ Trying commit 09d7ce8 with merge 98da694...

bors added a commit that referenced this pull request Nov 4, 2019
[experiment] Test ConstProp performance

Experiment to see performance implications for turning on ConstProp for scalars.

r? @ghost
@bors
Copy link
Contributor

bors commented Nov 4, 2019

☀️ Try build successful - checks-azure
Build commit: 98da694 (98da694a4fda38435d86b0eb6f09d4f644ef83d4)

@rust-timer
Copy link
Collaborator

Queued 98da694 with parent 0d5264a, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 98da694, comparison URL.

@oli-obk oli-obk added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 6, 2019
@oli-obk
Copy link
Contributor

oli-obk commented Nov 6, 2019

@rfcbot poll I think we should turn on constant propagation unconditionally (so in release mode and additionally in debug mode) since it reduces the work that llvm has to do quite a bit. Right now there is no real degradation of the debugging experience, since the worst that happens to users is that 2 + 2 shows up as 4 in the assembly and the debug info is still completely available, since it is attached to the temporary holding the 4 (or the result of 2 + 2 before this PR).

In the future we may const prop function calls to const fns, if that is deemed overkill for debug mode, we can always add an additional check that prevents function calls from being propagated in debug mode.

Constant propagation does not propagate over user defined variables, only expressions (so MIR temporaries) are const propagated. This may change in the future, but we can reopen the debug info degradation question then.

@rfcbot
Copy link

rfcbot commented Nov 6, 2019

Team member @oli-obk has asked teams: T-compiler, for consensus on:

I think we should turn on constant propagation unconditionally (so in release mode and additionally in debug mode) since it reduces the work that llvm has to do quite a bit. Right now there is no real degradation of the debugging experience, since the worst that happens to users is that 2 + 2 shows up as 4 in the assembly and the debug info is still completely available, since it is attached to the temporary holding the 4 (or the result of 2 + 2 before this PR).

@eddyb
Copy link
Member

eddyb commented Nov 6, 2019

Note that post-#56231 you don't even need to care about debuginfo or "temp vs var", all you have to do is leave assignments around and run the pass to remove dead locals (which won't remove locals that have debuginfo attached).

@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

1 similar comment
@varkor
Copy link
Member

varkor commented Nov 8, 2019

@rfcbot reviewed

@michaelwoerister
Copy link
Member

I think we should turn on constant propagation unconditionally (so in release mode and additionally in debug mode)

Are the numbers above already with constant propagation turned on for debug builds too?

@wesleywiser
Copy link
Member Author

wesleywiser commented Nov 8, 2019

I think we should turn on constant propagation unconditionally (so in release mode and additionally in debug mode)

Are the numbers above already with constant propagation turned on for debug builds too?

@michaelwoerister Yes, the results are with constant propagation turned on for both debug and release builds.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 10, 2019
…ovements, r=oli-obk

[mir-opt] Handle return place in ConstProp and improve SimplifyLocals pass

Temporarily rebased on top of rust-lang#66074. The top 2 commits are new.

r? @oli-obk
perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.

`ConstProp` doesn't currently intern the memory used by its `Machine` so
we can't yet propagate allocations which is why
`ConstProp::should_const_prop()` checks if the value being propagated is
a scalar or not.
@wesleywiser wesleywiser changed the title [experiment] Test ConstProp performance [mir-opt] Turn on the ConstProp pass by default Nov 12, 2019
@wesleywiser
Copy link
Member Author

This is ready for a final review.

r? @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Nov 12, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Nov 12, 2019

📌 Commit db5fc10 has been approved by oli-obk

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 12, 2019
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 13, 2019
…oli-obk

[mir-opt] Turn on the `ConstProp` pass by default

perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.
bors added a commit that referenced this pull request Nov 13, 2019
Rollup of 13 pull requests

Successful merges:

 - #65932 (download .tar.xz if python3 is used)
 - #66074 ([mir-opt] Turn on the `ConstProp` pass by default)
 - #66094 (Fix documentation for `Iterator::count()`.)
 - #66166 (rename cfg(rustdoc) into cfg(doc))
 - #66227 (docs: Fix link to BufWriter::flush)
 - #66292 (add Result::map_or)
 - #66297 (Add a callback that allows compiler consumers to override queries.)
 - #66317 (Use a relative bindir for rustdoc to find rustc)
 - #66330 (Improve non-exhaustiveness handling in usefulness checking)
 - #66331 (Add some tests for fixed ICEs)
 - #66334 (Move Session fields to CrateStore)
 - #66335 (Move self-profile infrastructure to data structures)
 - #66337 (Remove dead code for encoding/decoding lint IDs)

Failed merges:

r? @ghost
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 13, 2019
…oli-obk

[mir-opt] Turn on the `ConstProp` pass by default

perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.
@Centril
Copy link
Contributor

Centril commented Nov 13, 2019

@bors rollup=never

@wesleywiser
Copy link
Member Author

@bors r-

I'd like to resolve #66342 before this is merged.

@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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 13, 2019
@joelpalmer
Copy link

Ping from Triage: Hi @wesleywiser I see #66342 was closed yesterday. Please update this PR when you have a chance. Thanks!

@wesleywiser
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Nov 19, 2019

📌 Commit db5fc10 has been approved by oli-obk

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 19, 2019
@bors
Copy link
Contributor

bors commented Nov 19, 2019

⌛ Testing commit db5fc10 with merge d1da802...

bors added a commit that referenced this pull request Nov 19, 2019
[mir-opt] Turn on the `ConstProp` pass by default

perf.rlo shows that running the `ConstProp` pass results in
across-the-board wins regardless of debug or opt complilation mode. As a
result, we're turning it on to get the compile time benefits.
@bors
Copy link
Contributor

bors commented Nov 19, 2019

☀️ Test successful - checks-azure
Approved by: oli-obk
Pushing d1da802 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 19, 2019
@bors bors merged commit db5fc10 into rust-lang:master Nov 19, 2019
@tesuji
Copy link
Contributor

tesuji commented Nov 20, 2019

Performance result: https://perf.rust-lang.org/compare.html?start=5c5a1209583d5ac0de67f57e0f1cd8ca28aa6c05&end=d1da8023dafd3e277b5a4c5475aa2cb199a176b9&stat=instructions%3Au

bors added a commit to rust-lang/rust-clippy that referenced this pull request Nov 23, 2019
Rustup to rustc 1.41.0-nightly (35ef33a 2019-11-21)

I don't have the right fix for the fmtstr tests, and I'm also hitting problems caused by messense/rustc-test#3

List of rustups:
- rust-lang/rust#66271 (syntax: Keep string literals in ABIs and `asm!` more precisely)
- rust-lang/rust#65355 (Stabilize `!` in Rust 1.41.0)
- rust-lang/rust#66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`)
- rust-lang/rust#66389 (Specific labels when referring to "expected" and "found" types)
- rust-lang/rust#66074 ([mir-opt] Turn on the `ConstProp` pass by default)

changelog: none
bors added a commit to rust-lang/rust-clippy that referenced this pull request Nov 23, 2019
Rustup to rustc 1.41.0-nightly (35ef33a 2019-11-21)

I don't have the right fix for the fmtstr tests, and I'm also hitting problems caused by messense/rustc-test#3

List of rustups:
- rust-lang/rust#66271 (syntax: Keep string literals in ABIs and `asm!` more precisely)
- rust-lang/rust#65355 (Stabilize `!` in Rust 1.41.0)
- rust-lang/rust#66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`)
- rust-lang/rust#66389 (Specific labels when referring to "expected" and "found" types)
- rust-lang/rust#66074 ([mir-opt] Turn on the `ConstProp` pass by default)

changelog: none
bors added a commit to rust-lang/rust-clippy that referenced this pull request Nov 23, 2019
Rustup to rustc 1.41.0-nightly (35ef33a 2019-11-21)

I don't have the right fix for the fmtstr tests, and I'm also hitting problems caused by messense/rustc-test#3

List of rustups:
- rust-lang/rust#66271 (syntax: Keep string literals in ABIs and `asm!` more precisely)
- rust-lang/rust#65355 (Stabilize `!` in Rust 1.41.0)
- rust-lang/rust#66515 (Reduce size of `hir::Expr` by boxing more of `hir::InlineAsm`)
- rust-lang/rust#66389 (Specific labels when referring to "expected" and "found" types)
- rust-lang/rust#66074 ([mir-opt] Turn on the `ConstProp` pass by default)

changelog: none
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. 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.