perf(es/parser): micro-optimize parser hot paths#11859
Conversation
🦋 Changeset detectedLatest commit: ae6ab6d The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will improve performance by 2.83%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | es/large/parser |
36.3 ms | 35 ms | +3.61% |
| ⚡ | typescript/fast-strip |
403 µs | 389.5 µs | +3.47% |
| ⚡ | es/parser/angular |
14.4 ms | 14 ms | +2.89% |
| ⚡ | es/parser/jquery mobile |
17.9 ms | 17.4 ms | +2.92% |
| ⚡ | es/parser/mootools |
9 ms | 8.8 ms | +2.51% |
| ⚡ | es/parser/three |
56 ms | 54.6 ms | +2.51% |
| ⚡ | es/parser/typescript |
317.8 ms | 308.2 ms | +3.09% |
| ⚡ | es/parser/underscore |
2 ms | 1.9 ms | +2.59% |
| ⚡ | es/parser/backbone |
2.3 ms | 2.2 ms | +2.24% |
| ⚡ | es/parser/jquery |
11.6 ms | 11.3 ms | +2.94% |
| ⚡ | es/parser/yui |
8.9 ms | 8.7 ms | +2.35% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing hardfist:codex/ecma-parser-micro-optimize (ae6ab6d) with main (2ab1b8a)2
Footnotes
-
31 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(4c44d5d) during the generation of this report, so 2ab1b8a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Description:
Micro-optimize
swc_ecma_parserhot paths using local Valgrind/Cachegrind simulation data. This builds on the prior parser optimization work and focuses on the TypeScript parser benchmark input.Changes in this PR:
(subscript path whenno_callalready forbids consuming calls.Micro-Optimization Progress
Target benchmark:
swc_ecma_parserTypeScript parser input (crates/swc_ecma_parser/benches/files/typescript.js)Measurement mode: isolated Valgrind Cachegrind run with parser-harness client requests around the parse loop
Primary metric: Cachegrind
I refsBaseline commit:
25b2b1fb5cOptimized commit:
ae6ab6d2ebef0a84219etypescript.jsparse, 1 iter621283573dtypescript.jsparse, 1 iterd10b5e49b6typescript.jsparse, 1 iter5016fa25fatypescript.jsparse, 1 itere2a78b422ctypescript.jsparse, 1 iterae6ab6d2ebtypescript.jsparse, 1 iterae6ab6d2ebtypescript.jsparse, 1 iterae6ab6d2ebtypescript.jsparse, 1 iterae6ab6d2ebtypescript.jsparse, 1 iterArtifacts kept locally under ignored
optimization-artifacts/valgrind/cachegrind/:20260516T045236Z-baseline-isolated-typescript-cache-1iter20260516T082221Z-no-call-lparen-fast-return-typescript-cache-1iter20260516T082607Z-subscript-lparen-branch-typescript-cache-1iterValidation:
ae6ab6d2eb:git submodule update --init --recursiveae6ab6d2eb:cargo fmt --allae6ab6d2eb:cargo test -p swc_ecma_parser --features verifyae6ab6d2eb:cargo test -p swc_ecma_parser --features flow,verifyae6ab6d2eb:cargo clippy --all --all-targets -- -D warningscargo test -p swc_commonKnown local baseline issue:
cargo test -p swc_ecma_parserwithoutverifyfailserrors_tests__typescript_errors__type_only_import_specifier__invalid_type_only__input_ts; the same one-test command fails on the clean branch HEAD without the latest local diff and passes with--features verify. CI usescargo test -p swc_ecma_parser --features verifyfor this crate.BREAKING CHANGE:
None.
Related issue (if exists):
None.