tschneidereit opened PR #13876 from tschneidereit:hostcall-opts to bytecodealliance:main:
This set of commits applies a bunch of independent optimizations to calling host imports from components. In combination, they reduce overhead of sync calls by about 84%, from 83ns to 13ns, and that of immediately-ready async host imports by about 62%, from 142ns to 53ns. All numbers measured in a Linux VM on an M5 Max MBP, but I don't think any of this is particularly architecture-specific.
A few of notes on the results:
- I have a change to wit-bindgen pending that reduces guest-side overhead of async calls, bringing the 53ns down to something like 35ns.
- The fast paths introduced here only work for calls that don't involve borrows. I have changes pending that expand coverage and improve performance for calls involving borrows, but those need more vetting.
- Calls to async functions whose results aren't immediately ready are substantially slower, IIRC the last number I measured was about 700ns. There's more to be done there, but I didn't want to expand scope here too much.
All commits can be reviewed independently and come with improvement numbers relative to the previous commit.
tschneidereit requested dicej for a review on PR #13876.
tschneidereit requested wasmtime-core-reviewers for a review on PR #13876.
github-actions[bot] added the label wasmtime:api on PR #13876.
tschneidereit added the label performance on PR #13876.
tschneidereit added the label wasm-proposal:component-model on PR #13876.
tschneidereit updated PR #13876.
tschneidereit updated PR #13876.
alexcrichton commented on PR #13876:
Thanks! Could this be split up to land each commit independently? Some of these I'm more sure about than others and might take more time to review
alexcrichton unassigned dicej from PR #13876 Component hostcall optimizations.
alexcrichton requested alexcrichton for a review on PR #13876.
tschneidereit commented on PR #13876:
Happy to do that, yes! I might in that case also restructure some of them a little bit to bring in some borrows-related fixes which change some of the new code again.
Last updated: Jul 29 2026 at 05:03 UTC