-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
macro_rules: Preserve all metavariable spans in a global side table #119673
Conversation
r? @cjgillot (rustbot has picked a reviewer for you, use r? to override) |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
macro_rules: Preserve all metavariable spans in a global side table This is the first part of rust-lang#119412. TODO: write a more detailed description after a perf run.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (3dd649f): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 668.367s -> 668.851s (0.07%) |
Okay, let's try a light version - the new table insertion logic is disabled for undelimited sequences |
This comment has been minimized.
This comment has been minimized.
macro_rules: Preserve all metavariable spans in a global side table This is the first part of rust-lang#119412. TODO: write a more detailed description after a perf run.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (b8494cc): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 667.404s -> 668.154s (0.11%) |
While I'm on holidays I'm just going to run rust-perf in the background, without benchmarking anything myself. |
This comment has been minimized.
This comment has been minimized.
…ors,cjgillot macro_rules: Preserve all metavariable spans in a global side table This PR preserves spans of `tt` metavariables used to pass tokens to declarative macros. Such metavariable spans can then be used in span combination operations like `Span::to` to improve all kinds of diagnostics. Spans of non-`tt` metavariables are currently kept in nonterminal tokens, but the long term plan is remove all nonterminal tokens from rustc parser and rely on the proc macro model with invisible delimiters (rust-lang#114647, rust-lang#67062). In particular, `NtIdent` nonterminal (corresponding to `ident` metavariables) becomes easy to remove when this PR lands (rust-lang#119412 does it). The metavariable spans are kept in a global side table keyed by `Span`s of original tokens. The alternative to the side table is keeping them in `SpanData` instead, but the performance regressions would be large because any spans from tokens passed to declarative macros would stop being inline and would work through span interner instead, and the penalty would be paid even if we never use the metavar span for the given original span. (But also see the comment on `fn maybe_use_metavar_location` describing the map collision issues with the side table approach.) There are also other alternatives - keeping the metavar span in `Token` or `TokenTree`, but associating it with `Span` itsel is the most natural choice because metavar spans are used in span combining operations, and those operations are not necessarily tied to tokens.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r=compiler-errors,cjgillot |
☀️ Test successful - checks-actions |
Finished benchmarking commit (2bf78d1): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 640.58s -> 641.709s (0.18%) |
macro_rules: Remove `NtIdent` nonterminal token It only exists for keeping the second span (the metavariable span), but after rust-lang#119673 such spans can be kept using a more general mechanism.
Some icount regressions here. Was the idea that the perf improvements in #119693 justified the regressions here? |
If regressions in the final run are smaller than in the previous run (#119673 (comment)), then #119693 is responsible for that. In general, with this PR we are doing more work (tracking more spans), so some regressions are expected. |
@rustbot label: +perf-regression-triaged |
macro_rules: Remove `NtIdent` nonterminal token It only exists for keeping the second span (the metavariable span), but after rust-lang#119673 such spans can be kept using a more general mechanism.
macro_rules: Remove `NtIdent` nonterminal token It only exists for keeping the second span (the metavariable span), but after rust-lang#119673 such spans can be kept using a more general mechanism.
This PR preserves spans of
tt
metavariables used to pass tokens to declarative macros.Such metavariable spans can then be used in span combination operations like
Span::to
to improve all kinds of diagnostics.Spans of non-
tt
metavariables are currently kept in nonterminal tokens, but the long term plan is remove all nonterminal tokens from rustc parser and rely on the proc macro model with invisible delimiters (#114647, #67062).In particular,
NtIdent
nonterminal (corresponding toident
metavariables) becomes easy to remove when this PR lands (#119412 does it).The metavariable spans are kept in a global side table keyed by
Span
s of original tokens.The alternative to the side table is keeping them in
SpanData
instead, but the performance regressions would be large because any spans from tokens passed to declarative macros would stop being inline and would work through span interner instead, and the penalty would be paid even if we never use the metavar span for the given original span.(But also see the comment on
fn maybe_use_metavar_location
describing the map collision issues with the side table approach.)There are also other alternatives - keeping the metavar span in
Token
orTokenTree
, but associating it withSpan
itsel is the most natural choice because metavar spans are used in span combining operations, and those operations are not necessarily tied to tokens.