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

Simplify MatcherPos some more #95509

Merged
merged 5 commits into from
Apr 2, 2022

Conversation

nnethercote
Copy link
Contributor

A few more improvements.

r? @petrochenkov

Currently, we detect an exit from a `Delimited` submatcher when `idx`
exceeds the bounds of the current submatcher *and* there is a `stack`
entry.

This commit changes it to something simpler: just look for a
`CloseDelim` token.
It's redundant w.r.t. other fields.
By adding comments, and improving an assertion. I finally fully
understand this part!
`parse_tt` needs a way to get from within submatchers make to the
enclosing submatchers. Currently it has two distinct mechanisms for
this:
- `Delimited` submatchers use `MatcherPos::stack` to record stuff about
  the parent (and further back ancestors).
- `Sequence` submatchers use `MatcherPosSequence::parent` to point to
  the parent matcher position.

Having two mechanisms is really confusing, and it took me a long time to
understand all this.

This commit eliminates `MatcherPos::stack`, and changes `Delimited`
submatchers to use the same mechanism as sequence submatchers. That
mechanism is also changed a bit: instead of storing the entire parent
`MatcherPos`, we now only store the necessary parts from the parent
`MatcherPos`.

Overall this is a small performance win, with the positives outweighing
the negatives, but it's mostly for clarity.
It's only used in one place, and there we clone and then make a bunch of
modifications. It's clearer if we duplicate more explicitly, and there's
a symmetry now between `sequence()` and `empty_sequence()`.
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 31, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2022
@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 Mar 31, 2022
@bors
Copy link
Contributor

bors commented Mar 31, 2022

⌛ Trying commit c6fedd4 with merge 72313871ade2e188e761c3432e0dbe5b8428258e...

@bors
Copy link
Contributor

bors commented Mar 31, 2022

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

@rust-timer
Copy link
Collaborator

Queued 72313871ade2e188e761c3432e0dbe5b8428258e with parent a39ac5a, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (72313871ade2e188e761c3432e0dbe5b8428258e): comparison url.

Summary: This benchmark run shows 11 relevant improvements 🎉 to instruction counts.

  • Arithmetic mean of relevant improvements: -0.4%
  • Largest improvement in instruction counts: -0.7% on incr-unchanged builds of deep-vector check

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.

@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 Mar 31, 2022
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 31, 2022

📌 Commit c6fedd4 has been approved by petrochenkov

@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 Mar 31, 2022
@bors
Copy link
Contributor

bors commented Apr 2, 2022

⌛ Testing commit c6fedd4 with merge 95f6870...

@bors
Copy link
Contributor

bors commented Apr 2, 2022

☀️ Test successful - checks-actions
Approved by: petrochenkov
Pushing 95f6870 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 2, 2022
@bors bors merged commit 95f6870 into rust-lang:master Apr 2, 2022
@rustbot rustbot added this to the 1.61.0 milestone Apr 2, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (95f6870): comparison url.

Summary:

  • Primary benchmarks: no relevant changes found. 6 results were found to be statistically significant but too small to be relevant.
  • Secondary benchmarks: no relevant changes found. 4 results were found to be statistically significant but too small to be relevant.
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 6 4 6
mean2 N/A N/A -0.4% -0.6% -0.4%
max N/A N/A -0.5% -0.8% 0.0%

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

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

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.

None yet

6 participants