Skip to content

Comments

refactor(oxfmt): simplify wrap_format_embeded#15798

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-17-refactor_oxfmt_simplify_wrap_format_embeded
Nov 18, 2025
Merged

refactor(oxfmt): simplify wrap_format_embeded#15798
graphite-app[bot] merged 1 commit intomainfrom
11-17-refactor_oxfmt_simplify_wrap_format_embeded

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Nov 17, 2025

call_async does the same thing as call_with_return_value + channel, so use call_async to simplify it and reduce some unnecessary overhead

Benchmark

I benchmarked this PR locally, and the results indicate that it is 9% faster than before in the Outline repo.

EDIT: Maybe just a noise since Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interference from other programs. was displayed.

Setup complete! Run 'pnpm run bench' to start benchmarking.
=========================================
JavaScript/TypeScript Formatter Benchmark
=========================================

Formatters: Prettier, Biome, Oxfmt

Starting benchmark with:
- 3 warmup runs
- 10 benchmark runs
- Git reset before each run


=========================================
Benchmarking parser.ts (single large file)
=========================================
Benchmark 1: biome
  Time (mean ± σ):      69.5 ms ±   0.9 ms    [User: 55.4 ms, System: 9.7 ms]
  Range (min … max):    68.3 ms …  71.2 ms    10 runs
 
Benchmark 2: oxfmt-new
  Time (mean ± σ):      30.7 ms ±   0.3 ms    [User: 23.7 ms, System: 11.0 ms]
  Range (min … max):    30.3 ms …  31.3 ms    10 runs
 
Benchmark 3: oxfmt-old
  Time (mean ± σ):      30.4 ms ±   0.3 ms    [User: 23.6 ms, System: 10.6 ms]
  Range (min … max):    30.1 ms …  30.9 ms    10 runs
 
Summary
  oxfmt-old ran
    1.01 ± 0.01 times faster than oxfmt-new
    2.29 ± 0.04 times faster than biome

=========================================
Benchmarking Outline repository
=========================================
Benchmark 1: biome
  Time (mean ± σ):     154.6 ms ±   6.0 ms    [User: 825.2 ms, System: 555.8 ms]
  Range (min … max):   147.5 ms … 164.0 ms    10 runs
 
Benchmark 2: oxfmt-new
  Time (mean ± σ):      65.8 ms ±   2.3 ms    [User: 196.0 ms, System: 265.3 ms]
  Range (min … max):    60.7 ms …  68.8 ms    10 runs
 
Benchmark 3: oxfmt-old
  Time (mean ± σ):      72.0 ms ±  17.7 ms    [User: 195.0 ms, System: 277.3 ms]
  Range (min … max):    62.6 ms … 121.1 ms    10 runs
 
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.
 
Summary
  oxfmt-new ran
    1.09 ± 0.27 times faster than oxfmt-old
    2.35 ± 0.12 times faster than biome

@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter labels Nov 17, 2025
Copy link
Member Author

Dunqing commented Nov 17, 2025


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-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Nov 17, 2025
@Dunqing Dunqing changed the base branch from main to graphite-base/15798 November 18, 2025 02:31
@Dunqing Dunqing force-pushed the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch from 3757667 to a67086a Compare November 18, 2025 02:31
@Dunqing Dunqing changed the base branch from graphite-base/15798 to 11-07-perf_formatter_use_arenavec_and_arenabox November 18, 2025 02:31
@Dunqing Dunqing marked this pull request as ready for review November 18, 2025 02:32
@Dunqing Dunqing force-pushed the 11-07-perf_formatter_use_arenavec_and_arenabox branch from f0e48a1 to 28f5485 Compare November 18, 2025 02:39
@Dunqing Dunqing force-pushed the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch from a67086a to 4f0cd3f Compare November 18, 2025 02:39
@graphite-app graphite-app bot changed the base branch from 11-07-perf_formatter_use_arenavec_and_arenabox to graphite-base/15798 November 18, 2025 03:44
@graphite-app graphite-app bot force-pushed the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch from 4f0cd3f to d30c779 Compare November 18, 2025 03:51
@graphite-app graphite-app bot changed the base branch from graphite-base/15798 to main November 18, 2025 03:52
@graphite-app graphite-app bot force-pushed the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch from d30c779 to 48d52c1 Compare November 18, 2025 03:52
@Dunqing Dunqing requested a review from leaysgur November 18, 2025 06:12
@leaysgur
Copy link
Member

Just FYI, you may or may not know:

  • The outline repository contains 26 files that include css`...`
  • But there are only 4 of them do not contain substitution
    • = cases where the current oxc_formatter calls Prettier

So while the benchmark might not be very reliable, I still think this approach is better. 😅

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
Copy link
Member

leaysgur commented Nov 18, 2025

Merge activity

`call_async` does the same thing as `call_with_return_value` + `channel`, so use `call_async` to simplify it and reduce some unnecessary overhead

### Benchmark

I benchmarked this PR locally, and the results indicate that it is 9% faster than before in the `Outline` repo.

EDIT: Maybe just a noise since `Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interference from other programs.` was displayed.

```shell

Setup complete! Run 'pnpm run bench' to start benchmarking.
=========================================
JavaScript/TypeScript Formatter Benchmark
=========================================

Formatters: Prettier, Biome, Oxfmt

Starting benchmark with:
- 3 warmup runs
- 10 benchmark runs
- Git reset before each run

=========================================
Benchmarking parser.ts (single large file)
=========================================
Benchmark 1: biome
  Time (mean ± σ):      69.5 ms ±   0.9 ms    [User: 55.4 ms, System: 9.7 ms]
  Range (min … max):    68.3 ms …  71.2 ms    10 runs

Benchmark 2: oxfmt-new
  Time (mean ± σ):      30.7 ms ±   0.3 ms    [User: 23.7 ms, System: 11.0 ms]
  Range (min … max):    30.3 ms …  31.3 ms    10 runs

Benchmark 3: oxfmt-old
  Time (mean ± σ):      30.4 ms ±   0.3 ms    [User: 23.6 ms, System: 10.6 ms]
  Range (min … max):    30.1 ms …  30.9 ms    10 runs

Summary
  oxfmt-old ran
    1.01 ± 0.01 times faster than oxfmt-new
    2.29 ± 0.04 times faster than biome

=========================================
Benchmarking Outline repository
=========================================
Benchmark 1: biome
  Time (mean ± σ):     154.6 ms ±   6.0 ms    [User: 825.2 ms, System: 555.8 ms]
  Range (min … max):   147.5 ms … 164.0 ms    10 runs

Benchmark 2: oxfmt-new
  Time (mean ± σ):      65.8 ms ±   2.3 ms    [User: 196.0 ms, System: 265.3 ms]
  Range (min … max):    60.7 ms …  68.8 ms    10 runs

Benchmark 3: oxfmt-old
  Time (mean ± σ):      72.0 ms ±  17.7 ms    [User: 195.0 ms, System: 277.3 ms]
  Range (min … max):    62.6 ms … 121.1 ms    10 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.

Summary
  oxfmt-new ran
    1.09 ± 0.27 times faster than oxfmt-old
    2.35 ± 0.12 times faster than biome
```
@graphite-app graphite-app bot force-pushed the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch from 48d52c1 to 56a99d5 Compare November 18, 2025 06:29
@graphite-app graphite-app bot merged commit 56a99d5 into main Nov 18, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 11-17-refactor_oxfmt_simplify_wrap_format_embeded branch November 18, 2025 06:35
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Nov 18, 2025
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
`call_async` does the same thing as `call_with_return_value` + `channel`, so use `call_async` to simplify it and reduce some unnecessary overhead

### Benchmark

I benchmarked this PR locally, and the results indicate that it is 9% faster than before in the `Outline` repo.

EDIT: Maybe just a noise since `Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interference from other programs.` was displayed.

```shell

Setup complete! Run 'pnpm run bench' to start benchmarking.
=========================================
JavaScript/TypeScript Formatter Benchmark
=========================================

Formatters: Prettier, Biome, Oxfmt

Starting benchmark with:
- 3 warmup runs
- 10 benchmark runs
- Git reset before each run

=========================================
Benchmarking parser.ts (single large file)
=========================================
Benchmark 1: biome
  Time (mean ± σ):      69.5 ms ±   0.9 ms    [User: 55.4 ms, System: 9.7 ms]
  Range (min … max):    68.3 ms …  71.2 ms    10 runs

Benchmark 2: oxfmt-new
  Time (mean ± σ):      30.7 ms ±   0.3 ms    [User: 23.7 ms, System: 11.0 ms]
  Range (min … max):    30.3 ms …  31.3 ms    10 runs

Benchmark 3: oxfmt-old
  Time (mean ± σ):      30.4 ms ±   0.3 ms    [User: 23.6 ms, System: 10.6 ms]
  Range (min … max):    30.1 ms …  30.9 ms    10 runs

Summary
  oxfmt-old ran
    1.01 ± 0.01 times faster than oxfmt-new
    2.29 ± 0.04 times faster than biome

=========================================
Benchmarking Outline repository
=========================================
Benchmark 1: biome
  Time (mean ± σ):     154.6 ms ±   6.0 ms    [User: 825.2 ms, System: 555.8 ms]
  Range (min … max):   147.5 ms … 164.0 ms    10 runs

Benchmark 2: oxfmt-new
  Time (mean ± σ):      65.8 ms ±   2.3 ms    [User: 196.0 ms, System: 265.3 ms]
  Range (min … max):    60.7 ms …  68.8 ms    10 runs

Benchmark 3: oxfmt-old
  Time (mean ± σ):      72.0 ms ±  17.7 ms    [User: 195.0 ms, System: 277.3 ms]
  Range (min … max):    62.6 ms … 121.1 ms    10 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs.

Summary
  oxfmt-new ran
    1.09 ± 0.27 times faster than oxfmt-old
    2.35 ± 0.12 times faster than biome
```
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-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants