Sandvoxel opened PR #14517 from Sandvoxel:component-host-glue-mono to bytecodealliance:main:
HostFn::run returned a HostResult enum with a Future variant, so the sync and async lowering paths always contained the poll_and_block and first_poll arms. Those are monomorphized per host closure, so every func_wrap, func_wrap_async, func_new and func_new_async host function compiled its own copy of the future path, even though only the concurrent constructors can return a future.
This replaces the enum with a small HostOutput trait implemented for Result and for the boxed future. Only the future impl calls poll_and_block and first_poll, so they're only compiled for concurrent host functions. No public API or behavior change.
For the wasmtime CLI this cuts the wasmtime-cli crate's LLVM IR by 26% (7.4M to 5.5M lines), its peak compile memory from 3.3 GB to 2.5 GB, and the release binary from 65.8 MB to 60.8 MB. On an embedder with around 2,000 bindgen imports the fat LTO link peak went from 18.6 GB to 16.4 GB.
This overlaps a little with #13876. Its poll_once fast path would move into the future impl.
Testing
cargo test --test all,component-async-tests,wasmtime-wasiandwasmtime-wasi-http(p3) pass.cargo check -p wasmtimewithoutcomponent-model-async.benches/call.rscomponent wasm-to-host benches are unchanged within noise.
Sandvoxel requested dicej for a review on PR #14517.
Sandvoxel requested wasmtime-core-reviewers for a review on PR #14517.
github-actions[bot] added the label wasmtime:api on PR #14517.
:thumbs_up: dicej submitted PR review:
Thanks, @Sandvoxel!
dicej added PR #14517 Don't instantiate concurrent hostcall glue for non-concurrent host functions to the merge queue.
:check: dicej merged PR #14517.
dicej removed PR #14517 Don't instantiate concurrent hostcall glue for non-concurrent host functions from the merge queue.
QuantumSegfault commented on PR #14517:
@alexcrichton
Could we get this backported for the upcoming 50 release?
alexcrichton commented on PR #14517:
Sure thing, done at https://github.com/bytecodealliance/wasmtime/pull/14604
Last updated: Oct 11 2026 at 04:10 UTC