Repository navigation
perf: disable native unwind info for wasm plugins - #1391
Merged
Merged
Conversation
This reverts commit 57d3f6d.
On macOS, wasmtime registers each compiled function's unwind info with libunwind one at a time under a global lock when a module is loaded, and deregisters it the same way when the module is freed. Loading several plugins in parallel contended on that lock, making a single-file `dprint fmt --stdin` take ~25-30ms instead of ~9ms. The unwind info is only used by the system unwinder and tools like profilers to walk through wasm frames. Wasmtime's own wasm backtraces don't need it. Windows requires it, so it stays enabled there. This also makes the early exit from #1388 unnecessary, which was reverted in the previous commit.
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.
Reverts #1388 (including its test) and fixes the underlying cost instead, by not generating native unwind info for wasm plugins.
On macOS, wasmtime registers each compiled function's unwind info with libunwind one at a time under a global lock when a module is loaded (and deregisters it the same way when it's freed, which is what #1388 avoided). With several plugins loading in parallel, most runs spent ~20ms of system time contending on that lock. Wasmtime's docs for
Config::native_unwind_infocall out this behavior and suggest disabling it when loading many modules.The unwind info is only used by the system unwinder and tools like profilers to walk through wasm frames. Wasmtime's own wasm backtraces and trap handling don't need it, and frame pointers are still preserved. Windows requires it, so it stays enabled there. The setting is part of wasmtime's compatibility check, so existing cached compiled modules are recompiled once on upgrade.
Benchmarks
macOS 26.3, Apple M2 Pro.
hyperfine -N --warmup 5 --runs 60 'dprint fmt --stdin a.json'with{"a":1}as input, from the repo root (8 wasm plugins + exec) and with a wasm-only copy of the config. Each binary has its own cache directory. Two rounds each.main)On
main, timings are bimodal: a few runs finish in ~9 ms and most take 25-35 ms, mostly system time. Loading the modules one at a time instead of in parallel also brought it to ~11 ms, which points to lock contention. With unwind info disabled, the early exit from #1388 makes no measurable difference.