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

Optimize pattern matching #90746

Merged
merged 1 commit into from
Nov 11, 2021
Merged

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Nov 10, 2021

These commits speed up the match-stress-enum benchmark, which is very artificial, but the changes are simple enough that it's probably worth doing.

r? @Nadrieril

It's hot in the `match-stress-enum` benchmark.
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 10, 2021
@nnethercote nnethercote removed the request for review from Nadrieril November 10, 2021 01:24
@nnethercote
Copy link
Contributor Author

r? @Nadrieril

@nnethercote
Copy link
Contributor Author

@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 Nov 10, 2021
@bors
Copy link
Contributor

bors commented Nov 10, 2021

⌛ Trying commit f432a6447dba5e33ce3e6b759d8734f84a4fffb4 with merge 1235f8bc80de02dd823a68d66eb2c97f9f50d473...

@bors
Copy link
Contributor

bors commented Nov 10, 2021

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

@rust-timer
Copy link
Collaborator

Queued 1235f8bc80de02dd823a68d66eb2c97f9f50d473 with parent 8b09ba6, future comparison URL.

@est31
Copy link
Member

est31 commented Nov 10, 2021

@nnethercote congrats to your new job! It's extremely good news for the Rust project to see that you are back 🎉 .

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1235f8bc80de02dd823a68d66eb2c97f9f50d473): comparison url.

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

  • Very large improvement in instruction counts (up to -22.3% on full builds of match-stress-enum)
  • Very large regression in instruction counts (up to 6.2% on incr-unchanged builds of inflate)

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. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 10, 2021
@nnethercote
Copy link
Contributor Author

For instruction counts it's a big win on match-stress-enum and a moderate win on unicode_normalization. I think the inflate opt incr-unchanged regression is noise, I couldn't replicate it locally and this change is a small optimization to pattern matching in the front-end, with no functional change, so if there was any regression for inflate it would affect most or all of the builds and runs.

For cycles and wall-time the wins are smaller but still present.

@Nadrieril Nadrieril added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label Nov 10, 2021
@nnethercote
Copy link
Contributor Author

After discussion with @Nadrieril, we decided the second commit isn't useful for real code, it's too targeted towards the highly artificial match-stress-enum. (See rust-lang/rustc-perf#792 for more about that benchmark).

@nnethercote
Copy link
Contributor Author

@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 Nov 10, 2021
@bors
Copy link
Contributor

bors commented Nov 10, 2021

⌛ Trying commit 580d357 with merge b103b623e78e73e1b16c11e3abed576ec7075c1b...

@bors
Copy link
Contributor

bors commented Nov 11, 2021

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

@rust-timer
Copy link
Collaborator

Queued b103b623e78e73e1b16c11e3abed576ec7075c1b with parent 68ca579, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b103b623e78e73e1b16c11e3abed576ec7075c1b): comparison url.

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

  • Very large improvement in instruction counts (up to -5.3% on full builds of match-stress-enum)
  • Moderate regression in instruction counts (up to 0.5% on full builds of deeply-nested-async)

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 Nov 11, 2021
@Nadrieril
Copy link
Member

Wow big improvements for such a small change :D

@bors r+

@bors
Copy link
Contributor

bors commented Nov 11, 2021

📌 Commit 580d357 has been approved by Nadrieril

@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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 11, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 11, 2021
@bors
Copy link
Contributor

bors commented Nov 11, 2021

⌛ Testing commit 580d357 with merge 936238a...

@bors
Copy link
Contributor

bors commented Nov 11, 2021

☀️ Test successful - checks-actions
Approved by: Nadrieril
Pushing 936238a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 11, 2021
@bors bors merged commit 936238a into rust-lang:master Nov 11, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 11, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (936238a): comparison url.

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

  • Very large improvement in instruction counts (up to -5.3% on full builds of match-stress-enum)
  • Large regression in instruction counts (up to 4.0% on incr-unchanged builds of deep-vector)

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

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@nnethercote nnethercote deleted the opt-pattern-matching branch February 25, 2022 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

9 participants