Repository navigation
create fast path for attributes created in builtin macro expansions - #164260
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
create fast path for attributes created in derive expansions
This comment has been minimized.
This comment has been minimized.
|
@bors cancel |
|
❗ There is currently no auto build in progress on this PR. Hint: There is a pending try build on this PR. Maybe you meant to cancel it? You can do that using |
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
create fast path for attributes created in derive expansions
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (88e073e): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.8%, secondary 1.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.5%, secondary -3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.812s -> 488.427s (-0.28%) |
72e8279 to
5f34fef
Compare
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
create fast path for attributes created in derive expansions
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9abeeac to
1515f1b
Compare
This comment has been minimized.
This comment has been minimized.
| DocComment(CommentKind, Symbol), | ||
|
|
||
| /// A macro generated attribute inserted by a builtin macro. | ||
| Generated(GeneratedAttr), |
There was a problem hiding this comment.
I'd really like to see the AttrKind::Synthetic and AttrKind::Generated be merged.
They're basically the same concept. I have no strong preferences about the naming
I saw @nnethercote proposed this in #164260 (comment) as well, but I didn't see this addressed.
There was a problem hiding this comment.
They're a little different: synthetic ones cannot be written by hand and cannot be pretty-printed, while generated ones can (in both cases). IMO this is probably enough to justify keeping them separate.
There was a problem hiding this comment.
I'd say the way they're generated is indeed different, and they need a different path in pretty printing (every variant is already handled individually there anyways so that's fine), but they basically behave the same. I don't really see the advantage to keeping them separate, and the disadvantage is more code.
There was a problem hiding this comment.
I'd prefer the compiler to crash if they re-enter the parser somehow, rather than be silently swallowed like the trace attributes are.
There was a problem hiding this comment.
I agree that that's desirable. I think you can still relatively easily make it work, it would be one extra match where the trace attributes are allowed, and a wildcard arm is unreachable
There was a problem hiding this comment.
I think there's enough difference between them to justify having different enum variants. I'd rather this isn't an implicit thing, and having different variants/types makes for a good place to put this documentation
There was a problem hiding this comment.
Since you both seem to agree that keeping them separate is better lets do that.
I'm not entirely convinced it's worth it, but don't feel strongly enough to block this PR on this.
1515f1b to
db2155b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
There was a problem hiding this comment.
@bors r=JonathanBrouwer,nnethercote
Thanks! :3
The perf improvement makes me very happy
|
@bors r=JonathanBrouwer,nnethercote rollup=iffy force |
…rouwer,nnethercote create fast path for attributes created in builtin macro expansions Emitting attributes in rustc_builtin_macros involves creating an `ast::Attribute` and token trees, just to parse that into a parsed attribute almost immediately. This PR sidesteps that by creating a new `ast::Attribute` variant that does not do this. I've taken care to only do this for the derive and test macros, so that they never re-enter the parser. This results in some moderate performance gains. It'll also take away almost all of the regressions in rust-lang#164217 (comment) (see rust-lang#164281 (comment) for a perf run of this and that PR stacked) r? @nnethercote
…uwer Rollup of 3 perf-sensitive pull requests Successful merges: - #163845 (Add various `#[inline]` annotations for simple functions on hot paths that don't get inlined) - #164122 (Don't emit allow attributes in try/contract desugaring) - #164260 (create fast path for attributes created in builtin macro expansions) Failed merges: - #164790 (Split `LintLevelsBuilder::add` into `add_ast` and `add_hir`)
…rouwer,nnethercote create fast path for attributes created in builtin macro expansions Emitting attributes in rustc_builtin_macros involves creating an `ast::Attribute` and token trees, just to parse that into a parsed attribute almost immediately. This PR sidesteps that by creating a new `ast::Attribute` variant that does not do this. I've taken care to only do this for the derive and test macros, so that they never re-enter the parser. This results in some moderate performance gains. It'll also take away almost all of the regressions in rust-lang#164217 (comment) (see rust-lang#164281 (comment) for a perf run of this and that PR stacked) r? @nnethercote
…uwer Rollup of 4 perf-sensitive pull requests Successful merges: - #163845 (Add various `#[inline]` annotations for simple functions on hot paths that don't get inlined) - #164122 (Don't emit allow attributes in try/contract desugaring) - #164260 (create fast path for attributes created in builtin macro expansions) - #164300 (Deduplicate DefId encodings in the query cache) Failed merges: - #164790 (Split `LintLevelsBuilder::add` into `add_ast` and `add_hir`)
…uwer Rollup of 4 perf-sensitive pull requests Successful merges: - #163845 (Add various `#[inline]` annotations for simple functions on hot paths that don't get inlined) - #164122 (Don't emit allow attributes in try/contract desugaring) - #164260 (create fast path for attributes created in builtin macro expansions) - #164300 (Deduplicate DefId encodings in the query cache) Failed merges: - #164790 (Split `LintLevelsBuilder::add` into `add_ast` and `add_hir`)
…uwer Rollup of 5 pull requests Successful merges: - #163845 (Add various `#[inline]` annotations for simple functions on hot paths that don't get inlined) - #164122 (Don't emit allow attributes in try/contract desugaring) - #164260 (create fast path for attributes created in builtin macro expansions) - #164300 (Deduplicate DefId encodings in the query cache) - #164929 (Revert "rustc_codegen_gcc subtree update") Failed merges: - #164790 (Split `LintLevelsBuilder::add` into `add_ast` and `add_hir`)
Rollup merge of #164260 - mejrs:generated_attrs, r=JonathanBrouwer,nnethercote create fast path for attributes created in builtin macro expansions Emitting attributes in rustc_builtin_macros involves creating an `ast::Attribute` and token trees, just to parse that into a parsed attribute almost immediately. This PR sidesteps that by creating a new `ast::Attribute` variant that does not do this. I've taken care to only do this for the derive and test macros, so that they never re-enter the parser. This results in some moderate performance gains. It'll also take away almost all of the regressions in #164217 (comment) (see #164281 (comment) for a perf run of this and that PR stacked) r? @nnethercote
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (5d7c38d): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.4%, secondary 1.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.6%, secondary -1.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Artifact size: 405.91 MiB -> 406.05 MiB (0.03%) |
View all comments
Emitting attributes in rustc_builtin_macros involves creating an
ast::Attributeand token trees, just to parse that into a parsed attribute almost immediately. This PR sidesteps that by creating a newast::Attributevariant that does not do this. I've taken care to only do this for the derive and test macros, so that they never re-enter the parser.This results in some moderate performance gains. It'll also take away almost all of the regressions in #164217 (comment) (see #164281 (comment) for a perf run of this and that PR stacked)
r? @nnethercote