perf(estree/tokens): serialize tokens to compact JSON#19572
Conversation
Merging this PR will improve performance by 29.22%
Performance Changes
Comparing Footnotes
|
9a5717b to
8afb7c5
Compare
569de0d to
28f1ac3
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to optimize performance by converting ESTree tokens to compact JSON instead of pretty-printed JSON. The optimization is based on the fact that the JSON is immediately parsed on the JavaScript side, so whitespace formatting serves no purpose and only increases the payload size.
Changes:
- Modified
to_estree_tokens_jsonto useserde_json::to_string(compact) instead ofserde_json::to_string_pretty - Added new
to_estree_tokens_pretty_jsonfunction for generating pretty-printed JSON when needed - Updated test coverage code to use the new pretty-printed function
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_estree_tokens/src/lib.rs | Refactored to_estree_tokens_json to use compact JSON serialization and added to_estree_tokens_pretty_json for pretty-printed output |
| tasks/coverage/src/tools.rs | Updated test coverage functions to import and call to_estree_tokens_pretty_json instead of to_estree_tokens_json |
8afb7c5 to
f2726e9
Compare
28f1ac3 to
b87d174
Compare
Perf optimization to converting tokens to ESTree JSON. Previously we serialized to pretty-printed JSON. Instead use compact JSON - it's just passed to `JSON.parse` on JS side, so there's no need for whitespace.
33cfd5a to
76d0960
Compare
76d0960 to
33cfd5a
Compare
Perf optimization to converting tokens to ESTree JSON. Previously we serialized to pretty-printed JSON. Instead use compact JSON - it's just passed to `JSON.parse` on JS side, so there's no need for whitespace.
33cfd5a to
8940f66
Compare

Perf optimization to converting tokens to ESTree JSON. Previously we serialized to pretty-printed JSON. Instead use compact JSON - it's just passed to
JSON.parseon JS side, so there's no need for whitespace.