Use bulk libunwind section registration when available - #14304
Open
macovedj wants to merge 1 commit into
Open
Conversation
Register and deregister whole .eh_frame sections with libunwind when both section APIs are available. Remember the registration mode for matching cleanup, and retain individual-FDE registration as the fallback. The libgcc path continues using its existing whole-section interface. On macOS, resolve the optional APIs at runtime from the library supplying the linked frame API. Verify the registration and deregistration identities and restrict lookup to that image so custom unwinders cannot mix registries. Cache the matched pair while allowing builds against older macOS SDKs. Add native registry lifecycle and x86-64 stack-walking tests on macOS and Linux, controlled API-availability and provider-mismatch tests, and a linked-provider fixture that exercises the real macOS loader.
macovedj
force-pushed
the
bulk-libunwind-compat
branch
from
September 9, 2026 12:59
25c4337 to
4ce868e
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.
I encountered performance issues when working with large Wasm modules similar to those described in issue #6541. That issue led to a configuration fix making it possible to opt out of native unwinding on macOS.
However,
libunwindprovides whole-section APIs that Wasmtime currently doesn’t use:__unw_add_dynamic_eh_frame_sectionand__unw_remove_dynamic_eh_frame_section. These allow registering full.eh_framesections rather than registering each frame description entry (FDE) individually.Testing against my large Wasm module, I measured the following median total process wall times, including teardown. Most of the improvement comes from teardown after the workload finishes.
For the x86-64 Linux measurements, I explicitly selected LLVM
libunwindinstead of the machine’s defaultlibgcc. LLVMlibunwindis also used by configurations such as Rust’s default static musl builds, Chimera Linux, and Gentoo’s LLVM profiles. The existinglibgccregistration path is unchanged.This PR checks whether both batch registration APIs are available and uses them when they are, falling back to the existing APIs otherwise.
The
native_unwind_walks_nested_wasm_framestest currently runs on x86-64 macOS and Linux. Developing it exposed an existing native stack-walking bug on ARM64 macOS, addressed in #14303. Once that fix lands, I can enable the test on ARM64 macOS as well.