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.
:memo: dishmaker submitted PR review.
:speech_balloon: dishmaker created PR review comment:
[kinda unrelated to runtime optimizations]
first_pollcurrently causes a lot of llvm-lines bloat and compile-time overhead.
Do you think it could be reduced by changing genericRtoBox<dyn Any + Send + 'static>?
Pin<Box<dyn Future<Output = Box<dyn Any + Send + 'static>> + Send + 'static>>
:memo: tschneidereit submitted PR review.
:speech_balloon: tschneidereit created PR review comment:
Do you think it could be reduced by changing generic
RtoBox<dyn Any + Send + 'static>?Who knows, maybe? But we'd most certainly have very very compelling evidence that that change doesn't negatively impact runtime performance. Which absent that evidence I would think to be somewhat likely, since it'd introduce a box and a virtual call at a very hot callsite.
This is important to keep in mind for your entire work around reducing the amount of LLVM IR generated: we'd be unlikely to give up even a tiny bit of runtime performance for all but the most massive compile time gains, if at all.
Last updated: Aug 30 2026 at 09:07 UTC