perf(ecma_parser): start oxc-style token payload rewrite#11812
Draft
perf(ecma_parser): start oxc-style token payload rewrite#11812
Conversation
|
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
Binary Sizes
Commit: 634d294 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This starts the long-lived
swc_ecma_parserperformance rewrite with a parser-facing token payload refactor that follows the oxc-style plan without changing the public parser API.What changed:
Buffernow owns separate current/lookahead token payload slots instead of saving and restoring lexertoken_valueduring genericpeek().Atoms on hot paths.Why this helps:
Buffer::peek()payload swap from the main parser hot path.Atomwork in TS/Flow ambiguity checks.Local benchmark spot checks on April 20, 2026:
es/parser/colors: from roughly4.16–4.59 µsto3.05–3.07 µses/lexer/colors: from roughly1.15–1.19 µsto0.90–0.93 µses/parser/typescript: measured at roughly51.3–52.5 msafter the changeValidation used:
git submodule update --init --recursivecargo fmt --allcargo test -p swc_ecma_parsercargo bench -p swc_ecma_parser --bench parser -- --warm-up-time 0.01 --measurement-time 0.01 'es/parser/colors'cargo bench -p swc_ecma_parser --bench lexer -- --warm-up-time 0.01 --measurement-time 0.01 'es/lexer/colors'cargo bench -p swc_ecma_parser --bench parser -- --warm-up-time 0.01 --measurement-time 0.01 'es/parser/typescript'This is phase 1 of the rewrite PR. After the Benchmark workflow finishes, I plan to use the CodSpeed report to choose the next optimization step.
BREAKING CHANGE:
None.
Related issue (if exists):
N/A