feat(component): add Accessor async InstancePre instantiation#13706
Open
Aditya1404Sal wants to merge 1 commit into
Open
feat(component): add Accessor async InstancePre instantiation#13706Aditya1404Sal wants to merge 1 commit into
Aditya1404Sal wants to merge 1 commit into
Conversation
Allow embedders inside run_concurrent to lazily instantiate prepared components into the current concurrent store. Signed-off-by: Aditya Salunkhe <aditya.salunkh919@gmail.com>
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.
Summary
Add
Accessor::instantiate_async, anAccessor-side helper for instantiating anInstancePreinto the current concurrent store.This is intended for embedders that are already inside
StoreContextMut::run_concurrentand need to instantiate prepared components while using the concurrent component runtime.Problem
Inside
run_concurrent, embedders are given anAccessorrather than a directStoreContextMut.That works for accessing store data with
Accessor::withand for calling already-instantiated component functions withcall_concurrent, but there is currently no public API for instantiating anInstancePreinto that same concurrent store.For hosts with dynamic component graphs, this makes lazy instantiation not-possible. In my use case I had to either:
run_concurrentThis is limiting for hosts that want to instantiate linked components on demand during async component execution.
Change
Add:
The method uses the existing
AccessorTLS mechanism to recover the current concurrent store and then delegates toInstancePre::instantiate_async.This keeps lazy instantiation within the active concurrent event loop, without requiring a separately-held
StoreContextMut.I would really appreciate feedback on whether this is the right API shape for exposing this capability (ie. through
Accessor)Validation
Added a component-model async test that:
Linker::instantiate_preStoreContextMut::run_concurrentInstancePretwice throughAccessor::instantiate_asynccall_concurrentRan:
cargo test --test all accessor_can_instantiate_pre cargo check -p wasmtime --features component-model,component-model-async,async