perf(transformer/tagged-template): add #[cold] hint to unlikely path#18034
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR adds a #[cold] attribute to the transform_tagged_template method to optimize performance by hinting to the compiler that tagged template expressions are rare. This allows the compiler to optimize the common path (non-tagged templates) in the enter_expression method.
Changes:
- Added
#[cold]attribute totransform_tagged_templatemethod with an explanatory comment
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@Dunqing Apologies for the stack of nits. I just thought I'd split it into multiple PRs so it's easy to see what each change does. Hopefully we won't have to touch this transform again for a long time, so I thought might as well make these changes now, and get it done with! |
|
Is it okay in a CSS-in-JS project? That would be common rather than rare, I think, but still less in terms of |
No worries! |
Dunqing
left a comment
There was a problem hiding this comment.
Feel free to merge if you think it is good!
I suspect that even in a CSS-in-JS project, other expressions like
|
Merge activity
|
Well to be honest I don't think it makes much difference either way. But I don't think it's bad, so merging. |
#18034) Follow-on after #15834. Tiny perf optimization. Tagged template literals are pretty rare. Add `#[cold]` attr to `transform_tagged_template` to hint to compiler that the branch for "yes, it's a tagged template" in `enter_expression` is unlikely to be taken. This should make the compiler make "not a tagged template" the default path.
70541d6 to
04f8379
Compare
d6236f7 to
8ee6f80
Compare
TIL, thank you! |

Follow-on after #15834. Tiny perf optimization. Tagged template literals are pretty rare. Add
#[cold]attr totransform_tagged_templateto hint to compiler that the branch for "yes, it's a tagged template" inenter_expressionis unlikely to be taken. This should make the compiler make "not a tagged template" the default path.