Stream: git-wasmtime

Topic: wasmtime / PR #14350 `component`: Defer host task creation


view this post on Zulip Wasmtime GitHub notifications bot (Sep 16 2026 at 19:56):

adamrk opened PR #14350 from adamrk:abk/deferred-host-task to bytecodealliance:main:

Defer creation of a HostTask and insertion of it in the Store until it is required. This is an optimization on wasm->host calls where the HostTask may not actually be needed. The HostTask is materialized if the host future actually suspends (doesn't return Ready on the first poll), or if it tries to lower a borrowed resource (which requires inserting its CallContext into the Store to get a persistent identifier for it).

The work is separated into 3 commits:

These are the changes I see in the wasm->host benchmarks:
Baseline benchmarks:

component-async/wasm-to-host
                        time:   [354.02 ns 366.83 ns 380.05 ns]
component-async/wasm-to-host-borrow
                        time:   [462.76 ns 479.96 ns 497.66 ns]
component-async/wasm-to-host-pending-once
                        time:   [2.5383 µs 2.6139 µs 2.6873 µs]

With changes:

component-async/wasm-to-host
                        time:   [283.83 ns 296.05 ns 308.65 ns]
                        change: [21.162% 17.822% 14.374%] (p = 0.00 < 0.05)
                        Performance has improved.
component-async/wasm-to-host-borrow
                        time:   [377.80 ns 392.33 ns 406.01 ns]
                        change: [31.982% 29.587% 26.924%] (p = 0.00 < 0.05)
                        Performance has improved.
component-async/wasm-to-host-pending-once
                        time:   [2.4307 µs 2.5107 µs 2.5932 µs]
                        change: [3.0505% +0.1437% +3.5901%] (p = 0.94 > 0.05)
                        No change in performance detected.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 16 2026 at 21:44):

github-actions[bot] added the label wasmtime:api on PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 12:35):

adamrk updated PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 13:07):

adamrk updated PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 15:14):

adamrk updated PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 16:00):

adamrk has marked PR #14350 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 16:00):

adamrk requested dicej for a review on PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 16:00):

adamrk requested wasmtime-core-reviewers for a review on PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 16:00):

adamrk requested alexcrichton for a review on PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 16:00):

adamrk requested wasmtime-default-reviewers for a review on PR #14350.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 19:42):

:thumbs_up: alexcrichton submitted PR review:

Some great wins, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 19:42):

:speech_balloon: alexcrichton created PR review comment:

Could this be moved into host_task_create? To the extent that set_thread is a somewhat-hot function and I think that's the only caller which would otherwise trigger this, it might help keep this function a bit leaner to move it over there. That might mess up and/or require moving around some debug assertions though

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 19:42):

:speech_balloon: alexcrichton created PR review comment:

Could you add a debug-assert on this branch that materialized_task is None?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 17 2026 at 19:42):

:speech_balloon: alexcrichton created PR review comment:

And, similarly, for handling deferred_host_call_context getting cleared above, could that move into the first_poll function or similar?


Last updated: Sep 20 2026 at 18:08 UTC