Skip to content

refactor(transformer/class-properties): move code out of transform_assignment_target#7701

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_
Dec 6, 2024
Merged

refactor(transformer/class-properties): move code out of transform_assignment_target#7701
graphite-app[bot] merged 1 commit intomainfrom
12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 6, 2024

Follow-on after #7697.

transform_assignment_target is inlined into enter_assignment_target visitor, so we want it to be as small as possible. Move assigning to target into transform_assignment_target_impl, which is the cold path.

The principle is that in the transformer the most important thing for performance is to optimize for the path which is "nothing to do here, exit".

Here we are only transforming object.#prop, but very few AssignmentTargets are object.#prop, so 99% of the time there is nothing to do. So we want to keep that "do nothing and exit" path as fast and small as possible.

In practice, the *target = assignment is only a single assembly operation, so this PR is a micro-optimization. But why not? Every little helps.

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 6, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Member Author

overlookmotel commented Dec 6, 2024

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 6, 2024
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 6, 2024

CodSpeed Performance Report

Merging #7701 will degrade performances by 3.14%

Comparing 12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_ (ac910ee) with main (ab3e1c3)

Summary

❌ 1 regressions
✅ 28 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main 12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_ Change
semantic[cal.com.tsx] 28.1 ms 29.1 ms -3.14%

@overlookmotel overlookmotel marked this pull request as ready for review December 6, 2024 14:55
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Fair enough!

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Dec 6, 2024
Copy link
Member

Dunqing commented Dec 6, 2024

Merge activity

  • Dec 6, 10:15 AM EST: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Dec 6, 10:15 AM EST: A user added this pull request to the Graphite merge queue.
  • Dec 6, 10:23 AM EST: A user merged this pull request with the Graphite merge queue.

…ssignment_target` (#7701)

Follow-on after #7697.

`transform_assignment_target` is inlined into `enter_assignment_target` visitor, so we want it to be as small as possible. Move assigning to `target` into `transform_assignment_target_impl`, which is the cold path.

The principle is that in the transformer the most important thing for performance is to optimize for the path which is "nothing to do here, exit".

Here we are only transforming `object.#prop`, but very few `AssignmentTarget`s are `object.#prop`, so 99% of the time there is nothing to do. So we want to keep that "do nothing and exit" path as fast and small as possible.

In practice, the `*target =` assignment is only a single assembly operation, so this PR is a micro-optimization. But why not? Every little helps.
@Dunqing Dunqing force-pushed the 12-06-refactor_transformer_class-properties_shorten_code branch from 7519d6a to e67e981 Compare December 6, 2024 15:15
@Dunqing Dunqing force-pushed the 12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_ branch from bef07bd to ac910ee Compare December 6, 2024 15:16
Base automatically changed from 12-06-refactor_transformer_class-properties_shorten_code to main December 6, 2024 15:20
@graphite-app graphite-app bot merged commit ac910ee into main Dec 6, 2024
@graphite-app graphite-app bot deleted the 12-06-refactor_transformer_class-properties_move_code_out_of_transform_assignment_target_ branch December 6, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-transformer Area - Transformer / Transpiler C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants