Skip to content

WASI 0.3 prep: 0.2 component build, scheduler timer queue, async design notes#497

Closed
stevedekorte wants to merge 4 commits into
masterfrom
wasi-async-prep
Closed

WASI 0.3 prep: 0.2 component build, scheduler timer queue, async design notes#497
stevedekorte wants to merge 4 commits into
masterfrom
wasi-async-prep

Conversation

@stevedekorte

Copy link
Copy Markdown
Member

Summary

Prep work toward WASI 0.3's native async, implementing the two migration steps that are buildable and testable with today's toolchain (wasi-sdk 25, wasmtime 42), plus a design doc for the 0.3 step itself.

  • WASI 0.2 component buildmake component produces build/bin/io_component.wasm (a real layer-1 component via wasm32-wasip2 + wasm-component-ld); make check-component runs the full Io suite against it.
  • Scheduler timer queueObject wait parks the calling coroutine with a deadline instead of busy-yielding. Expired timers re-enter the run queue on yield/pause; when nothing is runnable the VM blocks in one host wait until the nearest deadline (Scheduler idleUntilNextTimer) — the exact seam where a WASI 0.3 future<T> plugs in later. Two overlapping 1s waits: ~1.1s wall at ~4% CPU (previously 100% CPU spin or serialized sleeps).
  • Eval-loop fixes exposed by the above:
    • Parent-resume walk now skips dead ancestors (no saved frames); previously a coroutine finishing after its starter died hit the nested-eval early-return and stranded all parked coroutines.
    • New hasFinished flag on coroutines (exposed as Coroutine isFinished); pause/yield drop stale run-queue entries instead of resuming a finished coroutine, which restarted its body.
  • Docs — WASI 0.3 section on the Technical Notes WASM page; agents/WASI_ASYNC_PLAN.md with the 0.3 integration design, VM contracts to preserve, and upgrade triggers (wasmtime ≥ 46, wit-bindgen C async support).

Test plan

  • C eval-loop suite: 25/25
  • Io correctness suite on io_static: 243/243 (238 existing + 5 new in SchedulerTimerTest)
  • Same suite on the WASI 0.2 component: 243/243
  • Browser playwright suite: 83/83
  • Regression coverage verified negatively: disabling the dead-ancestor walk makes the suite fail

🤖 Generated with Claude Code

stevedekorte and others added 4 commits June 12, 2026 20:16
make component builds build/bin/io_component.wasm via wasi-sdk's
wasm32-wasip2 target and wasm-component-ld; make check-component runs
the Io correctness suite against it under wasmtime.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Object wait now parks the calling coroutine on a Scheduler timer queue
with a deadline. Expired timers re-enter the run queue on yield/pause;
when nothing is runnable but timers are pending, the VM blocks in a
single host wait until the nearest deadline (Scheduler
idleUntilNextTimer). That idle point is where a WASI 0.3 future<T>
will be awaited once host/toolchain support lands. Timed coroutines
now run concurrently (two overlapping 1s waits: ~1.1s wall, ~4% CPU,
previously a 100% CPU busy-spin or fully serialized sleeps).

wait uses condition-variable semantics — a finished child coroutine
resumes its parent directly, so pause can return early; wait re-parks
for the remaining time and removes stale timer entries.

Two eval-loop fixes this exposed:

- Dead-ancestor walk: when a coroutine finishes after the coroutine
  that started it already finished, the parent-resume walk hit the
  dead link and took the nestedEvalDepth early-return, stranding all
  parked coroutines. The walk now skips ancestors with no saved frames.

- Stale run-queue entries: a coroutine woken by the child-death walk
  while still queued in yieldingCoros leaves a stale entry; resuming
  it after it finished restarted its body (frameless coros look
  never-started). IoCoroutineData gains a hasFinished flag set by the
  eval loop on body completion (cleared at every deliberate restart
  site), exposed as Coroutine isFinished; pause/yield drop finished
  entries instead of resuming them.

Adds SchedulerTimerTest covering concurrent waits, timer wakeups
during yields, actor waits, and a regression test for the
dead-ancestor walk (verified to fail with the walk disabled).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds a WASI 0.3 section to the Technical Notes WASM page evaluating
how the native-async component model fits Io (stackless evaluator,
actor futures, the new scheduler idle point) and records the landed
migration steps. agents/WASI_ASYNC_PLAN.md maps future<T>/stream<T>
onto the scheduler seam, documents the VM contracts to preserve, and
lists the upgrade triggers (wasmtime 46, C toolchain async support).
Static HTML and llms-full.txt regenerated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds the source JPEGs for the chapter art (_originals), unused assets
(_unused), and the previous Introduction image.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stevedekorte

Copy link
Copy Markdown
Member Author

Superseded: this work was split into two separate merges on master — code (make component + scheduler timer queue) and docs/site (WASI 0.3 notes, Release Notes page). Both are now on master (no tagged release yet).

@stevedekorte stevedekorte deleted the wasi-async-prep branch June 13, 2026 16:42
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.

1 participant