Skip to content

perf(ast/estree): optimize serializing strings to JSON#11070

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-16-perf_ast_estree_optimize_serializing_strings_to_json
May 16, 2025
Merged

perf(ast/estree): optimize serializing strings to JSON#11070
graphite-app[bot] merged 1 commit intomainfrom
05-16-perf_ast_estree_optimize_serializing_strings_to_json

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented May 16, 2025

Optimize printing strings in ESTree serializer.

The main optimizations are:

  1. Search for characters which need escaping in batches of 16 bytes, to speed up search over longer strings.
  2. Move the initial search for characters which need escaping into a tight loop.

Additionally:

  1. Tighten up the rest of the code to remove bounds checks.

Copy link
Member Author


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 May 16, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 16, 2025

CodSpeed Instrumentation Performance Report

Merging #11070 will not alter performance

Comparing 05-16-perf_ast_estree_optimize_serializing_strings_to_json (8f8d823) with main (c29b1b8)

Summary

✅ 36 untouched benchmarks

@overlookmotel overlookmotel marked this pull request as ready for review May 16, 2025 11:38
@overlookmotel
Copy link
Member Author

Not much effect on estree benchmark, but I imagine it'd show a bigger gain on files with many longer strings (e.g. content-heavy websites).

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 16, 2025
Copy link
Member

Boshen commented May 16, 2025

Merge activity

Optimize printing strings in ESTree serializer.

The main optimizations are:

1. Search for characters which need escaping in batches of 16 bytes, to speed up search over longer strings.
2. Move the initial search for characters which need escaping into a tight loop.

Additionally:

3. Tighten up the rest of the code to remove bounds checks.
@graphite-app graphite-app bot force-pushed the 05-16-perf_ast_estree_optimize_serializing_strings_to_json branch from 734c5c6 to 8f8d823 Compare May 16, 2025 15:31
@graphite-app graphite-app bot merged commit 8f8d823 into main May 16, 2025
25 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 16, 2025
@graphite-app graphite-app bot deleted the 05-16-perf_ast_estree_optimize_serializing_strings_to_json branch May 16, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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