Conversation
adamrk
force-pushed
the
abk/deferred-host-task
branch
2 times, most recently
from
September 17, 2026 13:07
a19ed7d to
1a73b4f
Compare
adamrk
force-pushed
the
abk/deferred-host-task
branch
from
September 17, 2026 15:14
1a73b4f to
dc76ae5
Compare
adamrk
marked this pull request as ready for review
September 17, 2026 16:00
adamrk
requested review from
alexcrichton and
dicej
and removed request for
a team
September 17, 2026 16:00
alexcrichton
approved these changes
Sep 17, 2026
alexcrichton
left a comment
Member
There was a problem hiding this comment.
Some great wins, thanks!
| } | ||
| } | ||
| None => { | ||
| self.exit_call_not_concurrent(); |
Member
There was a problem hiding this comment.
Could you add a debug-assert on this branch that materialized_task is None?
| debug_assert!(context.is_empty()); | ||
| }; | ||
| if let CurrentThread::DeferredHost(_) = thread { | ||
| state.deferred_host_call_context = Some(CallContext::default()); |
Member
There was a problem hiding this 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
Member
There was a problem hiding this comment.
And, similarly, for handling deferred_host_call_context getting cleared above, could that move into the first_poll function or similar?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defer creation of a
HostTaskand insertion of it in theStoreuntil it is required. This is an optimization on wasm->host calls where theHostTaskmay not actually be needed. TheHostTaskis materialized if the host future actually suspends (doesn't returnReadyon the first poll), or if it tries to lower a borrowed resource (which requires inserting itsCallContextinto theStoreto get a persistent identifier for it).The work is separated into 3 commits:
u32identifier forCallContexts an proper enumHostTaskcreation.These are the changes I see in the wasm->host benchmarks:
Baseline benchmarks:
With changes: