Skip to content

Cross-VM resource budget: instantiation-state hooks + napi budget wiring - #6819

Open
Arshia001 wants to merge 1 commit into
mainfrom
cross-vm-resource-limits
Open

Cross-VM resource budget: instantiation-state hooks + napi budget wiring#6819
Arshia001 wants to merge 1 commit into
mainfrom
cross-vm-resource-limits

Conversation

@Arshia001

Copy link
Copy Markdown
Member

Stack 1/4 (wasmer). Base: main. → next: wasmer-scope-bound-lifetimes.

Wasmer-side of the cross-VM resource budget (companion to wasmerio/napi):

  • thread per-instantiation state through the runtime hooks; report instance-configuration failures distinctly; make the state types opaque
  • napi submodule bumps tracking the budget work (Phases 1–3, §7.1–7.3)

⚠️ Stacked chain, merge bottom-up; not yet mergeable (ECO-415/416 follow-ups open).

Copilot AI review requested due to automatic review settings July 24, 2026 14:23
@Arshia001
Arshia001 requested a review from syrusakbary as a code owner July 24, 2026 14:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Runtime hook APIs to return and consume an opaque InstantiationState, and updates PluggableRuntime/OverriddenRuntime to 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 WasiThreadError for 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_instance failures are also wrapped as RuntimeHookError without 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"))?;

Comment thread lib/wasix/src/state/linker/runtime_hooks.rs
Comment thread lib/cli/src/commands/run/mod.rs Outdated
@Arshia001
Arshia001 force-pushed the cross-vm-resource-limits branch 3 times, most recently from cba173b to 647317b Compare July 28, 2026 16:10
@Arshia001
Arshia001 force-pushed the cross-vm-resource-limits branch from 647317b to 29c8344 Compare August 4, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants