Skip to content

perf(estree/tokens): do not JSON-encode JSX identifiers#19812

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-22-perf_estree_tokens_do_not_json-encode_jsx_identifiers
Feb 27, 2026
Merged

perf(estree/tokens): do not JSON-encode JSX identifiers#19812
graphite-app[bot] merged 1 commit intomainfrom
om/02-22-perf_estree_tokens_do_not_json-encode_jsx_identifiers

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 27, 2026

Same as #19744, but for JSX identifiers. Serialize them using the same optimized EstreeIdentToken serializer added in this PR.

No effect on ESTree tokens benchmark, but the fixture file doesn't contain JSX. I imagine it'd be a sizeable improvement for JSX files.

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

overlookmotel commented Feb 27, 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will not alter performance

✅ 52 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-22-perf_estree_tokens_do_not_json-encode_jsx_identifiers (6d2668e) with om/02-22-perf_estree_tokens_handle_regex_tokens_separately (c0cea8e)

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.

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 extends the identifier token serialization optimization from #19744 to JSX identifiers. Instead of JSON-encoding JSX identifier tokens character-by-character, it uses the optimized EstreeIdentToken serializer which assumes the identifier name is JSON-safe and manually assembles the JSON with minimal bounds checking.

Changes:

  • Added emit_jsx_identifier method that uses serialize_ident_token for JSX identifiers
  • Replaced all emit_token_at calls for JSX identifiers with emit_jsx_identifier

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Feb 27, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 27, 2026

Merge activity

Same as #19744, but for JSX identifiers. Serialize them using the same optimized `EstreeIdentToken` serializer added in this PR.

No effect on ESTree tokens benchmark, but the fixture file doesn't contain JSX. I imagine it'd be a sizeable improvement for JSX files.
@graphite-app graphite-app bot force-pushed the om/02-22-perf_estree_tokens_handle_regex_tokens_separately branch from c0cea8e to 5016d92 Compare February 27, 2026 18:39
@graphite-app graphite-app bot force-pushed the om/02-22-perf_estree_tokens_do_not_json-encode_jsx_identifiers branch from 6d2668e to b378f4a Compare February 27, 2026 18:39
graphite-app bot pushed a commit that referenced this pull request Feb 27, 2026
…ns (#19814)

After #19744, #19813, #19812, and #19796, all tokens which require special handling or can contain `value`s which are possibly not JSON-safe are handled separately. So everything remaining (keywords, punctuators etc) are JSON-safe and can be serialized via the optimized serializer introduced for identifiers in #19744.

To reflect that `EstreeIdentToken` now handles a lot more than identifiers, rename it to `EstreeSafeToken`, and rename `EstreeToken` to `EstreeUnsafeToken`.

Large positive perf impact. +24% on ESTree tokens benchmark.
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 27, 2026
Base automatically changed from om/02-22-perf_estree_tokens_handle_regex_tokens_separately to main February 27, 2026 18:46
@graphite-app graphite-app bot merged commit b378f4a into main Feb 27, 2026
22 checks passed
@graphite-app graphite-app bot deleted the om/02-22-perf_estree_tokens_do_not_json-encode_jsx_identifiers branch February 27, 2026 18:47
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