Repository navigation
perf: compile wasm plugin functions in parallel - #1315
Merged
Merged
Conversation
Enables wasmtime's parallel-compilation feature and runs each plugin's compile on a shared rayon pool capped at DPRINT_MAX_THREADS. The pool only lives while something is compiling.
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.
Wasm plugins were already compiled at the same time as each other, but each module compiled its functions serially, so cold-cache startup was bound by the largest plugin (usually typescript).
This enables wasmtime's
parallel-compilationfeature and runs each compile on a shared rayon pool:Environment::max_threads(), soDPRINT_MAX_THREADSnow caps compile threads too.Costs: rayon becomes a dependency and the Windows release binary grows about 158 KB.
Measurements
Cold plugin cache, median of 5 runs of
dprint output-resolved-configagainst local.wasmfiles on a 32-core Windows machine. "5 plugins" is typescript, json, markdown, toml and dockerfile. Timings are whole-process wall time and land in roughly 100 ms steps, so small differences aren't meaningful.Pinned to N cores with CPU affinity:
All 32 cores available, varying
DPRINT_MAX_THREADS:Warm-cache runs are unaffected since the pool is never created.
Notes
DPRINT_MAX_THREADS=1on a many-core machine now compiles several plugins one after another (about 3.9 s vs 1.9 s for the five above), because the cap previously didn't apply to compilation.