Repository navigation
perf: format files in batches on the Wasm plugin's threads - #1476
Merged
Merged
Conversation
dsherret
force-pushed
the
perf-format-batches
branch
from
November 29, 2026 17:56
0878458 to
3171948
Compare
dsherret
force-pushed
the
perf-format-batches
branch
from
November 29, 2026 17:57
3171948 to
cc86d59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1475.
#1475 still sends each file to a Wasm instance's thread and waits for it on the runtime's single thread. This has the instance threads take the files from a shared queue instead, so the runtime thread does a little work for each batch of files rather than for every file.
run_parallelizedputs the files a single Wasm plugin formats in their entirety in a queue. For each permit it gets, it runs a batch on an instance's thread that formats files from the queue for up to 100 ms, then gives back the permit so throttling the CPU still works. It doesn't start more batches than there are files left, so formatting a few files doesn't create an instance for each permit.FormatThreadRequestno longer has one.--fail-fast), the other batches stop after their current file.InitializedPlugin::run_on_format_threadnow returnsResult<()>, andhas_format_threadsays whether a plugin supports it. Process plugins, files formatted by several plugins,--lines, and files that might be formatted because of their shebang line still go through the per-file path.dprint check --list-different --incremental=falsewith@dprint/tidy(Windows), on 21,073 files from vite, storybook and rolldown, compared with #1475:The gain is larger with fewer threads. The files
checkreports and the filesfmtproduces, with@dprint/tidyand with the standard plugins, are the same as before.