Repository navigation
id-worlds: guest calls in blocking context — first #1067 fair-scheduling slice (draft, awaiting reference-machine bench) - #12571
Merged
Conversation
added 2 commits
November 22, 2026 12:55
…nnot monopolize a hub worker (#1067) First scheduler slice for F12.10. A Wasm guest call executes synchronously inside its world actor and may burn its whole fuel budget (10,000,000 by default) in one execution. World actors share one Tokio runtime, so a fuel-spinning world parked a shared worker for the full span of every call and every other world's actor waited behind it — the contention the fuel_spin_isolation benchmark records (victim p99 ratio 2.517 against the 1.10 target on the reference laptop). WorldInstance guest calls (update, view, layout, records, wants, snapshot, restore) now run through run_guest_call: on a multi-thread runtime the call executes under tokio::task::block_in_place — the same guard world_store::recv_writer_reply already uses for the journal rendezvous (#557) — so the runtime hands the worker's other tasks to a replacement thread while the guest runs. Off a multi-thread runtime the call is direct, exactly as before. Fuel, ordering, and poisoning semantics are unchanged; the same call runs, just in blocking context. Tests (failing-first, in sandbox::tests): - spinning_guest_does_not_monopolize_a_runtime_worker: on a one-worker multi-thread runtime, a victim guest call completes while a spinning guest is still burning a 4e9 fuel budget. On main this fails with "victim guest call waited for the spinning guest's whole fuel budget"; with the change it passes, and the spin still ends in fuel exhaustion. - guest_calls_under_a_runtime_match_plain_thread_results_and_fuel: the wrap changes neither results nor fuel accounting. Local: cargo test -p id-worlds --lib --features sandbox -- sandbox:: → 38 passed, 0 failed (2 ignored, pre-existing).
…dominated (#1067) Four full-profile runs on the fleet runner (two on main, two on the blocking-context branch) span ratios 2.170-58.228, with identical code producing 2.500 and 58.228: at 4 visible CPUs / 3 spinners the spinning-phase p99 is neighbour noise. Recorded in BASELINES.md so the next #1067 worker runs the deciding pair on the reference machine class instead of re-learning the venue limit. No baseline lines change.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
dezren39
pushed a commit
that referenced
this pull request
Nov 22, 2026
Two back-to-back pre/post pairs on the laptop at light ambient load (full profile, same command): ratios indistinguishable (pre 6.049/6.711, post 6.826/6.085), wake tail persists, ack p99 worsens (3.963/6.456 -> 12.983/17.242 ms), and the victim's own spinning-phase command mean rises ~20x (67/103 -> 1,651/2,191 us, bucketed p99 2,000 -> 50,000 us) because every guest call now pays the block_in_place round trip under core saturation. Placement cannot create CPU; the supported next lever is admission - bounding concurrent guest burns. Pair lines appended to baseline.txt.
This was referenced Nov 22, 2026
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.
Refs #1067 — first scheduler slice for F12.10, opened as draft: the mechanism lands with a deterministic test, but the benchmark venue available to a sandbox lane cannot decide the ratio (evidence below), so this waits for a reference-machine bench pair before merge.
Summary
A Wasm guest call executes synchronously inside its world actor and may burn its whole fuel budget (10,000,000 by default) in one execution. World actors share one Tokio runtime, so a fuel-spinning world parked a shared worker for the full span of every call and every other world's actor waited behind it.
WorldInstanceguest calls (update, view, layout, records, wants, snapshot, restore) now run throughrun_guest_callincrates/id-worlds/src/sandbox.rs: on a multi-thread runtime the call executes undertokio::task::block_in_place— the same guardworld_store::recv_writer_replyalready uses for the journal rendezvous (#557) — so the runtime hands the worker's other tasks to a replacement thread while the guest runs. Off a multi-thread runtime the call is direct, exactly as before. Fuel, ordering, and poisoning semantics are unchanged.Also records the CI-runner measurement campaign in
pkgs/id/benches/BASELINES.md(no baseline lines change).Evidence
Mechanism tests (failing-first,
sandbox::tests):spinning_guest_does_not_monopolize_a_runtime_worker— on a one-worker multi-thread runtime, a victim guest call completes while a spinning guest is still burning a 4e9 fuel budget. On main it fails with "victim guest call waited for the spinning guest's whole fuel budget"; with the change it passes, and the spin still ends in fuel exhaustion.guest_calls_under_a_runtime_match_plain_thread_results_and_fuel— the wrap changes neither results nor fuel accounting.cargo test -p id-worlds --lib --features sandbox -- sandbox::→ 38 passed, 0 failed.cargo test -p id-worlds --features sandbox(fleet-run 45024947483) → 1024 passed, 1 failed. The one failure,write_lease_entries_require_journal_version_7, fails identically on unmodified mainc9fbfa0(MAX_JOURNAL_VERSION is 13 since the KV bump; the test pins 12) — pre-existing, filed as id-worlds: write_lease journal-version pin test fails on main (MAX_JOURNAL_VERSION 13 vs pinned 12) #12546, unrelated to this change.Benchmark (
fuel_spin_isolation, full profile, fleet runner — 4 visible CPUs, 3 spinners):c9fbfa0(run 45024947483)780ddbe(run 45024947483)780ddbe(run 45027312468)c9fbfa0(run 45027312468)Identical code spans ratios 2.500–58.228 on this venue: the spinning-phase p99 over 300 samples on shared 4-vCPU runners is neighbour noise, so no ratio verdict is claimed from these runs. The deciding measurement is a before/after pair on the reference machine class (16 threads, 15 spinners) where the 2.517 baseline in
BASELINES.mdwas recorded. Evidence level: mechanism measured deterministically in unit tests (sandbox); bench measured on the CI runner and found noise-dominated there; not run on the reference laptop.Merge danger
Low blast radius, one file of production code: every Wasm guest call on a multi-thread runtime gains a
block_in_placehandoff (the pattern #557 already pays on every journal append). Behaviour off multi-thread runtimes is byte-identical to today. The residual risk is per-call handoff overhead under saturation, which is part of what the reference-machine bench pair should look at. Nothing else in the PR touches production code.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.