Skip to content

perf(estree/tokens): serialize tokens to compact JSON#19572

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json
Feb 24, 2026
Merged

perf(estree/tokens): serialize tokens to compact JSON#19572
graphite-app[bot] merged 1 commit intomainfrom
om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 20, 2026

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.

Copy link
Member Author

overlookmotel commented Feb 20, 2026


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.

@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Feb 20, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 20, 2026

Merging this PR will improve performance by 29.22%

⚡ 1 improved benchmark
✅ 51 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation estree_tokens[checker.ts] 322.6 ms 249.7 ms +29.22%

Comparing om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json (112333d) with om/02-23-ci_benchmarks_correct_comment (e0476b5)2

Open in CodSpeed

Footnotes

  1. 3 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.

  2. No successful run was found on om/02-23-ci_benchmarks_correct_comment (ee9c4aa) during the generation of this report, so e66bff1 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel force-pushed the om/02-19-perf_parser_tokens_pre-allocate_capacity_for_tokens branch from 9a5717b to 8afb7c5 Compare February 23, 2026 16:11
@overlookmotel overlookmotel force-pushed the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch from 569de0d to 28f1ac3 Compare February 23, 2026 16:11
@overlookmotel overlookmotel changed the base branch from om/02-19-perf_parser_tokens_pre-allocate_capacity_for_tokens to graphite-base/19572 February 23, 2026 23:11
@overlookmotel overlookmotel marked this pull request as ready for review February 23, 2026 23:18
Copilot AI review requested due to automatic review settings February 23, 2026 23:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_json to use serde_json::to_string (compact) instead of serde_json::to_string_pretty
  • Added new to_estree_tokens_pretty_json function 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

@overlookmotel overlookmotel force-pushed the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch from 28f1ac3 to b87d174 Compare February 23, 2026 23:21
@overlookmotel overlookmotel changed the base branch from graphite-base/19572 to om/02-19-perf_parser_tokens_pre-allocate_capacity_for_tokens February 23, 2026 23:21
graphite-app bot pushed a commit that referenced this pull request Feb 24, 2026
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.
@graphite-app graphite-app bot force-pushed the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch from 33cfd5a to 76d0960 Compare February 24, 2026 15:33
@overlookmotel overlookmotel force-pushed the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch from 76d0960 to 33cfd5a Compare February 24, 2026 15:41
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.
@graphite-app graphite-app bot force-pushed the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch from 33cfd5a to 8940f66 Compare February 24, 2026 15:42
@graphite-app graphite-app bot merged commit 8940f66 into main Feb 24, 2026
21 checks passed
@graphite-app graphite-app bot deleted the om/02-20-perf_estree_tokens_serialize_tokens_to_compact_json branch February 24, 2026 15:49
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter-plugins Area - Linter JS plugins A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants