Cross-VM resource budget: instantiation-state hooks + napi budget wiring - #6819
Open
Arshia001 wants to merge 1 commit into
Open
Cross-VM resource budget: instantiation-state hooks + napi budget wiring#6819Arshia001 wants to merge 1 commit into
Arshia001 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Threads opaque per-instantiation state from Runtime::additional_imports into Runtime::configure_new_instance so runtime hooks (including N-API and Wasm C API wiring) can reliably pair pre-instantiation import creation with post-instantiation setup across concurrent instantiations.
Changes:
- Extends WASIX
Runtimehook APIs to return and consume an opaqueInstantiationState, and updatesPluggableRuntime/OverriddenRuntimeto route per-hook state correctly. - Wires the new instantiation-state flow through WASIX env instantiation and CLI runtime wrappers (N-API + Wasm C API), and introduces a distinct
WasiThreadErrorfor instance-configuration failures. - Refactors Wasm C API imports to carry per-instantiation session state explicitly, removing the global pending-session queue and adding targeted tests.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/wasix/src/state/linker/runtime_hooks.rs | Captures per-instantiation state from runtime hooks and passes it into instance configuration. |
| lib/wasix/src/state/env.rs | Propagates instantiation state through env instantiation and distinguishes configuration failures from import creation failures. |
| lib/wasix/src/runtime/mod.rs | Introduces InstantiationState + InstantiationHook and updates runtime implementations to pair import/setup phases. |
| lib/wasix/src/os/task/thread.rs | Adds InstanceConfigurationFailed to clearly classify post-instantiation setup failures. |
| lib/cli/src/commands/run/runtime.rs | Updates CLI monitoring runtime to forward the new hook signatures. |
| lib/cli/src/commands/run/mod.rs | Updates N-API and Wasm C API runtime wrappers to box/downcast instantiation state when configuring instances. |
| lib/c-api-imports/src/lib.rs | Moves Wasm C API hook pairing to explicit per-instantiation state (session), simplifying concurrency correctness and adding tests. |
| Cargo.lock | Updates locked dependency to wasmer-c-api-imports. |
Comments suppressed due to low confidence (2)
lib/wasix/src/state/linker/runtime_hooks.rs:34
configure_new_instancefailures are also wrapped asRuntimeHookErrorwithout indicating which phase failed. Add context here to make runtime-hook failures easier to diagnose from logs/error reports.
runtime
.configure_new_instance(
module,
&mut store_mut,
&instance,
lib/cli/src/commands/run/mod.rs:742
- If the instantiation-state downcast fails here, the error message is too generic to quickly identify what wiring is broken. Include the expected type name in the error message.
let state = *state
.context("missing Wasm C API instance setup state")?
.downcast::<wasmer_c_api_imports::WasmCapiInstantiationState>()
.map_err(|_| anyhow!("unexpected instance setup state"))?;
Arshia001
force-pushed
the
cross-vm-resource-limits
branch
3 times, most recently
from
July 28, 2026 16:10
cba173b to
647317b
Compare
Arshia001
force-pushed
the
cross-vm-resource-limits
branch
from
August 4, 2026 13:56
647317b to
29c8344
Compare
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.
Stack 1/4 (wasmer). Base:
main. → next:wasmer-scope-bound-lifetimes.Wasmer-side of the cross-VM resource budget (companion to wasmerio/napi):