Skip to content

perf: disable native unwind info for wasm plugins - #1391

Merged
dsherret merged 2 commits into
mainfrom
perf-disable-native-unwind-info
Oct 22, 2026
Merged

dsherret merged 2 commits into
mainfrom
perf-disable-native-unwind-info

Conversation

@dsherret

Copy link
Copy Markdown
Member

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_info call 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.

Unwind info #1388 exit Repo config Wasm-only config
on yes (main) 28.5 / 28.9 ms (σ 6 ms) 24.5 / 26.5 ms (σ 6 ms)
on reverted 32.0 / 28.6 ms 25.1 / 28.5 ms
off yes 9.3 / 9.4 ms (σ 0.5 ms) 7.6 / 7.7 ms (σ 0.3 ms)
off reverted (this PR) 9.2 / 9.3 ms (σ 0.4 ms) 7.2 / 7.7 ms (σ 0.3 ms)

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.

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.
@dsherret
dsherret merged commit 0ad0924 into main Oct 22, 2026
4 checks passed
@dsherret
dsherret deleted the perf-disable-native-unwind-info branch October 22, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant