-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Yet more parse_tt
improvements
#95425
Yet more parse_tt
improvements
#95425
Conversation
Some
|
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 89325098160f8ee473b0ebfc1b05c323254a1f19 with merge 87e9e2c9089a81be4a5b32d55832388b56a3e885... |
☀️ Try build successful - checks-actions |
Queued 87e9e2c9089a81be4a5b32d55832388b56a3e885 with parent ad5b6f6, future comparison URL. |
// != Meta-variable expressions` | ||
// RHS meta-variable expressions eventually end-up here. `0` is returned to inform that | ||
// no meta-variable was found, because "meta-variables" != "meta-variable | ||
// expressions". | ||
TokenTree::MetaVarExpr(..) => 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be unreachable, and count_metavars
should never be called when parsing RHS (parsing_patterns == false
) in the first place, it's 0 there by definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally thought that too, but if you make it unreachable these tests fail:
failures:
[ui] ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs
[ui] ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs
[ui] ui/macros/rfc-3086-metavar-expr/macro-expansion.rs
[ui] ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs
There may be something to clean up here, but I'd prefer to do it in a follow-up. This change was just meant to give this function a nicer name and slightly cleaner code, it wasn't doing anything about where/how it is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
Finished benchmarking commit (87e9e2c9089a81be4a5b32d55832388b56a3e885): comparison url. Summary: This benchmark run shows 45 relevant improvements 🎉 to instruction counts.
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 |
In particular: - Replace use of "item" with "matcher position/"mp". - Replace use of "repetition" with "sequence". - Replace `ms` with `matcher`.
Currently, matches within a sequence are recorded in a new empty `matches` vector. Then when the sequence finishes the matches are merged into the `matches` vector of the parent. This commit changes things so that a sequence mp inherits the matches made so far. This means that additional matches from the sequence don't need to be merged into the parent. `push_match` becomes more complicated, and the current sequence depth needs to be tracked. But it's a sizeable performance win because it avoids one or more `push_match` calls on every iteration of a sequence. The commit also removes `match_hi`, which is no longer necessary.
This avoids some allocations.
8932509
to
6b0a16a
Compare
I have updated the code to address comments. Most of the changes are in the relevant commits, but I split out the |
@bors r+ |
📌 Commit 6b0a16a has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c5cf08d): comparison url. Summary: This benchmark run shows 53 relevant improvements 🎉 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
expand: Do not count metavar declarations on RHS of `macro_rules` They are 0 by definition there. Addresses rust-lang#95425 (comment) r? `@nnethercote`
expand: Do not count metavar declarations on RHS of `macro_rules` They are 0 by definition there. Addresses rust-lang#95425 (comment) r? ``@nnethercote``
expand: Do not count metavar declarations on RHS of `macro_rules` They are 0 by definition there. Addresses rust-lang#95425 (comment) r? ```@nnethercote```
Including lots of comment improvements, and an overhaul of how
matches
work that gives big speedups.r? @petrochenkov