Files
YTandleaysgur 2766d07f6b perf(oxfmt): spawn Prettier workers on demand (#28789)
Follow-up to #28517 and #28787.

When the CLI needs Prettier and no worker is free, it spawns one worker,
up to `--threads` (default: the number of logical CPU cores). Spawned
workers stay alive for later files. Before this PR, the first file that
needs Prettier starts every worker.

## Results

`oxfmt --check` on AMD Ryzen 9 7940HS (16 threads), `main` at
8432de6b27, 30 runs per build. Values are means.

| Target | Node.js 24.21.0 | Node.js 26.12.1 |
|---|---:|---:|
| Synthetic: 1 Vue + 70 TS files | -41.5 ms (-26.7%) | -24.9 ms (-20.1%)
|
|
[toeverything/AFFiNE](https://github.com/toeverything/AFFiNE/tree/fbf2cebfa0)
| -61.0 ms (-18.6%) | -43.4 ms (-15.0%) |
| [Kong/insomnia](https://github.com/Kong/insomnia/tree/88ae88d6e5) |
-32.6 ms (-9.3%) | -20.7 ms (-6.8%) |
| [vuejs/core](https://github.com/vuejs/core/tree/0ff253bfba) | -22.8 ms
(-7.6%) | -16.9 ms (-6.5%) |
| [antfu/vitesse](https://github.com/antfu/vitesse/tree/a8785264f8) |
-19.9 ms (-8.0%) | -12.5 ms (-5.9%) |
|
[immich-app/immich](https://github.com/immich-app/immich/tree/afc5a2291e)
| -23.5 ms (-6.4%) | -9.0 ms (-2.8%) |
| [wxt-dev/wxt](https://github.com/wxt-dev/wxt/tree/f8ed652912) | -16.8
ms (-5.0%) | -4.2 ms (within noise) |

The other 9 targets are within noise on both versions: 2 synthetic
targets and tldraw, elk, starlight, zustand, outline, shoelace, and
social-app. The gain is largest when a project needs only a few Prettier
workers.

AI disclosure: the patch and the measurements were done with Claude
Code, and I reviewed them.

---------

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
2026-11-04 04:15:52 +00:00
..