adamrk opened PR #14468 from adamrk:abk/lower-without-fiber to bytecodealliance:main:
When lowering the result of a host function, we do the lowering on a separate fiber because it may call realloc which could yield and it's unsound for that to occur outside of a fiber.
But if we can determine from the result type that lowering will not realloc, then we can immediately lower in the host task future. This PR introduces that optimization.
I see a ~20% improvement in the benchmark for calling an async noop function which yields.
Baseline:
component-async/wasm-to-host-pending-once time: [2.0301 µs 2.0645 µs 2.1008 µs]Branch:
component-async/wasm-to-host-pending-once time: [1.6673 µs 1.6984 µs 1.7309 µs] change: [−22.923% −21.135% −19.370%] (p = 0.00 < 0.05) Performance has improved.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
adamrk requested pchickey for a review on PR #14468.
adamrk requested wasmtime-core-reviewers for a review on PR #14468.
github-actions[bot] added the label wasmtime:api on PR #14468.
:thumbs_up: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
Could this perhaps pessimistically return
true? The dynamic case is horribly slow for a bunch of other reasons and it additionally would mean that the environ changes above wouldn't be needed (if I'm undertanding this right)
adamrk updated PR #14468.
adamrk updated PR #14468.
:memo: adamrk submitted PR review.
:speech_balloon: adamrk created PR review comment:
Yep I removed the environ changes and just set this to be
truein theDynamicHostFncase.
adamrk updated PR #14468.
adamrk updated PR #14468.
alexcrichton added PR #14468 component: Lower without fiber to the merge queue.
github-merge-queue[bot] removed PR #14468 component: Lower without fiber from the merge queue.
alexcrichton added PR #14468 component: Lower without fiber to the merge queue.
github-merge-queue[bot] removed PR #14468 component: Lower without fiber from the merge queue.
alexcrichton added PR #14468 component: Lower without fiber to the merge queue.
:check: alexcrichton merged PR #14468.
alexcrichton removed PR #14468 component: Lower without fiber from the merge queue.
Last updated: Oct 11 2026 at 02:20 UTC