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

An optimization for pest-2.1.3 #98654

Merged
merged 2 commits into from
Jul 8, 2022
Merged

Conversation

nnethercote
Copy link
Contributor

An easy win I found while looking at a profile of pest-2.1.3. It's also a small code cleanup.

r? @pnkfelix

Because the `infcx` isn't needed. This removes one lifetime from
`Search`.
Currently, `search_for_structural_match_violation` constructs an `infcx`
from a `tcx` and then only uses the `tcx` within the `infcx`. This is
wasteful because `infcx` is a big type.

This commit changes it to use the `tcx` directly. When compiling
`pest-2.1.3`, this changes the memcpy stats reported by DHAT for a `check full`
build from this:
```
433,008,916 bytes (100%, 99,787.93/Minstr) in 2,148,668 blocks (100%, 495.17/Minstr), avg size 201.52 bytes
```
to this:
```
101,422,347 bytes (99.98%, 25,243.59/Minstr) in 1,318,407 blocks (99.96%, 328.15/Minstr), avg size 76.93 bytes
```
This translates to a 4.3% reduction in instruction counts.
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 29, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 29, 2022
@nnethercote
Copy link
Contributor Author

Local measurements indicate this won't affect any of the benchmarks in rustc-perf, but let's double-check:

@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 Jun 29, 2022
@bors
Copy link
Contributor

bors commented Jun 29, 2022

⌛ Trying commit 687e391 with merge 4fa72b1548083b2d460e63e36e69b987970bc89f...

@bors
Copy link
Contributor

bors commented Jun 29, 2022

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

@rust-timer
Copy link
Collaborator

Queued 4fa72b1548083b2d460e63e36e69b987970bc89f with parent 126e3df, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4fa72b1548083b2d460e63e36e69b987970bc89f): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-0.3% -0.3% 4
All 😿🎉 (primary) N/A N/A 0

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
1.1% 1.3% 2
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-3.7% -3.7% 1
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-3.3% -3.3% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -3.3% -3.3% 1

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 may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 29, 2022
@nnethercote
Copy link
Contributor Author

The only significant changes here are so small (< 0.3% on many-assoc-items) that I think it's fine to roll this up.

@bors rollup=always

@pnkfelix
Copy link
Member

pnkfelix commented Jul 7, 2022

I spent a little while trying to figure out why we were passing in an infcx in the first place, since clearly this change illustrates that it is currently not necessary. (Was it an artifact of some prior version of the code? Or was a planned enhancement for the future...?)

In the end, though, I couldn't find an answer, and I think that's okay. If it turns out we need infcx for some reason, we can thread it down at that time.

@pnkfelix
Copy link
Member

pnkfelix commented Jul 7, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 7, 2022

📌 Commit 687e391 has been approved by pnkfelix

It is now in the queue for this repository.

@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 Jul 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 8, 2022
Rollup of 4 pull requests

Successful merges:

 - rust-lang#98533 (Add a `-Zdump-drop-tracking-cfg` debugging flag)
 - rust-lang#98654 (An optimization for `pest-2.1.3`)
 - rust-lang#98657 (Migrate some diagnostics from `rustc_const_eval` to `SessionDiagnostic`)
 - rust-lang#98794 (Highlight conflicting param-env candidates)

Failed merges:

 - rust-lang#98957 ( don't allow ZST in ScalarInt )

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit fe87923 into rust-lang:master Jul 8, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 8, 2022
@nnethercote nnethercote deleted the pest-2.1.3-opt branch July 8, 2022 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants