Skip to content

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Jul 13, 2025

Remove quasis and expressions in batch instead of removing them one by one, so that it would be more efficient. Considering that the expression's removal is unlikely to be common, I add a has_deletion_marker flag to avoid unnecessary retain calls, so that we can keep the performance as before in this situation.

Copy link
Member Author

Dunqing commented Jul 13, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

@Dunqing Dunqing changed the title pref(transformer/styled-components): remove quasis and expressions in batch perf(transformer/styled-components): remove quasis and expressions in batch Jul 13, 2025
@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Jul 13, 2025
@Dunqing Dunqing force-pushed the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch from 7459b4d to b20f2ab Compare July 13, 2025 17:58
@codspeed-hq
Copy link

codspeed-hq bot commented Jul 13, 2025

CodSpeed Instrumentation Performance Report

Merging #12256 will not alter performance

Comparing 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch (a8d1e22) with main (6f58abc)

Summary

✅ 34 untouched benchmarks

@Dunqing Dunqing marked this pull request as ready for review July 13, 2025 18:10
@Dunqing Dunqing requested a review from overlookmotel as a code owner July 13, 2025 18:10
@graphite-app graphite-app bot changed the base branch from 07-12-fix_transform_styled-components_fix_spans_of_quasis_when_some_quasis_removed to graphite-base/12256 July 13, 2025 18:20
@graphite-app graphite-app bot force-pushed the graphite-base/12256 branch from 8152fe7 to fb76e3c Compare July 13, 2025 18:31
@graphite-app graphite-app bot force-pushed the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch from b20f2ab to f76ca34 Compare July 13, 2025 18:31
@graphite-app graphite-app bot changed the base branch from graphite-base/12256 to main July 13, 2025 18:32
@graphite-app graphite-app bot force-pushed the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch from f76ca34 to 85bdee6 Compare July 13, 2025 18:32
Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you say, this case is uncommon, but yes using retain is ideal to avoid poor perf in odd cases where there are tons of quasis and many get deleted. 👍

If we do #12213, then probably we'll be able to make the main loop use retain, and then we won't need the extra loops to remove nodes at the end.

@Dunqing Dunqing force-pushed the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch from 85bdee6 to 505b8db Compare July 15, 2025 07:39
@Dunqing Dunqing requested a review from overlookmotel July 15, 2025 08:27
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Jul 15, 2025
Copy link
Member

overlookmotel commented Jul 15, 2025

Merge activity

… batch (#12256)

Remove `quasis` and `expressions` in batch instead of removing them one by one, so that it would be more efficient. Considering that the expression's removal is unlikely to be common, I add a `has_deletion_marker` flag to avoid unnecessary `retain` calls, so that we can keep the performance as before in this situation.
@graphite-app graphite-app bot force-pushed the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch from 505b8db to a8d1e22 Compare July 15, 2025 09:56
@graphite-app graphite-app bot merged commit a8d1e22 into main Jul 15, 2025
24 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jul 15, 2025
@graphite-app graphite-app bot deleted the 07-14-pref_transformer_styled-components_remove_quasis_and_expressions_in_batch branch July 15, 2025 10:04
graphite-app bot pushed a commit that referenced this pull request Jul 15, 2025
Follow-on after #12256. Update comments to reflect the new removal logic. Also tidy up some other comments.
graphite-app bot pushed a commit that referenced this pull request Jul 15, 2025
Follow-on after #12256. Nit! Rename var to a name which reflects what the var *means*, rather than the implementation detail.
graphite-app bot pushed a commit that referenced this pull request Jul 15, 2025
Follow-on after #12256. Optimize the `retain` loop for removing quasis and expressions by doing bounds check only once at start, rather than on each turn of the loop.
graphite-app bot pushed a commit that referenced this pull request Jul 15, 2025
Follow-on after #12256. Optimize the `retain` loop for removing quasis and expressions by doing bounds check only once at start, rather than on each turn of the loop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants