Skip to content

perf(oxfmt): Try rust printer for .json#20177

Closed
leaysgur wants to merge 2 commits into03-09-fix_oxfmt_handle_literalline_for_script-in-vuefrom
03-10-perf_oxfmt_try_rust_printer_for_.json
Closed

perf(oxfmt): Try rust printer for .json#20177
leaysgur wants to merge 2 commits into03-09-fix_oxfmt_handle_literalline_for_script-in-vuefrom
03-10-perf_oxfmt_try_rust_printer_for_.json

Conversation

@leaysgur
Copy link
Member

Just experiments.

For now, .json files are handled:

  • Rust: Collect .json file
  • JS: Prettier formats it as Doc then print as string, then returns string
  • Rust: Save returned string

This PR changes this flow:

  • Rust: Collect .json file
  • JS: Prettier formats it as Doc then returns Doc JSON
  • Rust: Convert Doc into our IR, then print as string

Copy link
Member Author

leaysgur commented Mar 10, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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 changes, fast-track this PR to the front of the merge queue

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 Mar 10, 2026
@leaysgur
Copy link
Member Author

Target: Storybook repository (mixed with embedded languages)
- 3 warmup runs, 10 benchmark runs
- Git reset before each run

Benchmark 1: oxfmt-main --config ./oxfmtrc.json ./data/**/*.json
  Time (mean ± σ):     185.3 ms ±   1.6 ms    [User: 671.1 ms, System: 99.4 ms]
  Range (min … max):   182.7 ms … 187.3 ms    10 runs

Benchmark 2: oxfmt-dev --config ./oxfmtrc.json ./data/**/*.json
  Time (mean ± σ):     184.8 ms ±   2.5 ms    [User: 654.7 ms, System: 100.4 ms]
  Range (min … max):   181.5 ms … 189.0 ms    10 runs

Summary
  oxfmt-dev --config ./oxfmtrc.json ./data/**/*.json ran
    1.00 ± 0.02 times faster than oxfmt-main --config ./oxfmtrc.json ./data/**/*.json

Mixed (embedded) benchmark complete!

There isn't a significant difference.
Furthermore, as you can see from the conformance, the Doc to IR conversion isn't perfect either...

@leaysgur leaysgur closed this Mar 10, 2026
@leaysgur leaysgur deleted the 03-10-perf_oxfmt_try_rust_printer_for_.json branch March 10, 2026 07:17
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 10, 2026

Merging this PR will not alter performance

✅ 49 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing 03-10-perf_oxfmt_try_rust_printer_for_.json (59413ff) with main (542a04a)2

Open in CodSpeed

Footnotes

  1. 7 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 03-09-fix_oxfmt_handle_literalline_for_script-in-vue (7ad7521) during the generation of this report, so main (542a04a) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter 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.

1 participant