Windows caps a processβs command line at 32767 characters. Batches are
normally kept far below this to spread work across threads; this is only a
backstop for unusually long paths.
Spawning rustfmt costs more than formatting a handful of files, so batches
below this size are not worth the extra parallelism. Measured on this repo,
one process per file is ~3x slower than batching.
Choose how many files to put in each batch: enough batches to keep every
thread busy through the end of the run, but not so few files per batch that
process startup dominates.
Group every packageβs crate roots by edition. rustfmt walks mod
declarations itself, so these roots transitively cover every file that
cargo fmt would format.