Skip to content

refactor(parser): rewrite arrow function parsing to remove rewind in hot paths #11483

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

Conversation

camchenry
Copy link
Member

@camchenry camchenry commented Jun 4, 2025

This is a major work-in-progress. May not even be merged.

@github-actions github-actions bot added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Jun 4, 2025
Copy link
Member Author


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.

@camchenry camchenry force-pushed the 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free branch from 86d49d5 to d253194 Compare June 4, 2025 17:39
@Boshen
Copy link
Member

Boshen commented Jun 5, 2025

Best chance is to avoid rewind on hot path such as () => {}, x => {}, (x) => {} etc

@camchenry camchenry closed this Jun 5, 2025
@camchenry camchenry reopened this Jun 6, 2025
@camchenry camchenry force-pushed the 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free branch from d253194 to 44f8db0 Compare June 6, 2025 03:44
@camchenry camchenry changed the title refactor(parser): rewrite arrow function parsing to be lookahead-free refactor(parser): rewrite arrow function parsing to remove rewind in hot paths Jun 6, 2025
@camchenry camchenry force-pushed the 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free branch 2 times, most recently from 7efbae9 to a70f206 Compare June 8, 2025 01:13
Copy link

codspeed-hq bot commented Jun 8, 2025

CodSpeed Instrumentation Performance Report

Merging #11483 will degrade performances by 11.31%

Comparing 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free (08d8634) with main (bfa05f2)

Summary

❌ 3 regressions
✅ 35 untouched benchmarks

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

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[cal.com.tsx] 2.7 ms 3.1 ms -11.31%
parser[binder.ts] 3.4 ms 3.6 ms -5.42%
parser[react.development.js] 1.4 ms 1.4 ms -5.79%

@camchenry camchenry force-pushed the 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free branch from a70f206 to ae66138 Compare June 8, 2025 02:58
@camchenry camchenry force-pushed the 06-04-refactor_parser_rewrite_arrow_function_parsing_to_be_lookahead-free branch from ae66138 to 08d8634 Compare June 9, 2025 01:32
@camchenry
Copy link
Member Author

camchenry commented Jun 9, 2025

Okay, I've gotten this to a working state now. I need to verify that the hot paths don't rewind though. As evidenced above, just focus on arrow function parsing can have a huge effect since it's a commonly used feature. We are also rewinding in like 90% of the other cases, and only not rewinding on things like () => {} or () => expr.

@camchenry
Copy link
Member Author

Going to close this out as I don't have capacity right now to continue with this approach.

@camchenry camchenry closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser 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