Repository navigation
id-worlds: guest-burn admission - bound concurrent guest burns, charged per world (#1067 slice 2) - #12615
Conversation
RuntimeLimits gains guest_burn_concurrency (0 = auto), carried through resolve unchanged as a server bound rather than a per-world request, with a --world-guest-burn-concurrency flag on WorldRuntimeArgs via a defaulted WorldLimitArgs method.
…er-key charge (#1067) Bound concurrent synchronous guest burns with a shared GuestBurnBudget at the run_guest_call funnel: calls past the bound queue (never refused), grants go to the waiting key with the least attained service (settled fuel, decayed), and every call settles its measured fuel spend against its charge key — the counter the per-account quota criterion hangs off. restore_program charges burns to the world id against the configured budget; the bench labels its victim/spinner keys so charges persist across re-instantiations.
…g override (#1067) The profile line now ends with the guest burn budget counters (bound, in-flight high-water mark, victim admissions/waits) so a run shows whether admission engaged and whether the victim ever waited. ID_BENCH_GUEST_BURN_CONCURRENCY runs the workload on a dedicated budget of a chosen size for sizing experiments; unset, guests use the shared default (production shape). Facade re-exports id_worlds::guest_burn under the sandbox feature.
Interleaved pre/post fuel_spin_isolation on the reference machine: admission engages (in-flight max = the bound), ratio improves at matched load (4.725 -> 3.886/3.801), wake/ack p99 improve, but the exit shape is not met - the victim command mean stays ~1.4-2.0 ms at every bound tried (8/10/14), so the residual is scheduler contention around the burn path, not the burns themselves. target_met=false stands; full attribution in BASELINES.md.
|
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 30 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e2c7886b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| static CONFIGURED: OnceLock<Arc<GuestBurnBudget>> = OnceLock::new(); | ||
| CONFIGURED | ||
| .get_or_init(|| Arc::new(Self::new(max_concurrent))) |
There was a problem hiding this comment.
Apply the configured budget to live program installs
When the server sets a nonzero guest-burn concurrency limit, only restored programs use it: world_store::restore_program calls shared_for, while both installation paths in world_session/service.rs instantiate guests without replacing their default shared() budget. Because CONFIGURED and SHARED are separate singletons, newly installed programs ignore the configured limit, and restored and newly installed worlds can burn concurrently against independent pools. Configure one shared hub budget before opening or installing worlds, or explicitly pass the same configured budget through both installation paths.
Useful? React with 👍 / 👎.
| state.waiters.retain(|waiter| waiter.ticket != ticket); | ||
| Self::admit(&mut state, key); | ||
| break; |
There was a problem hiding this comment.
Wake the next waiter when admission leaves spare capacity
With a budget of at least two, multiple holders can release their permits before the awakened waiters resume. If a non-winning waiter obtains the mutex first, it goes back to sleep; the winning waiter then removes itself and admits without notifying the remaining waiters. This leaves available capacity unused until another running call releases, unnecessarily serializing queued burns and delaying guests despite a free permit. Notify the remaining waiters when a queued admission leaves spare capacity, or assign all available grants under the lock.
Useful? React with 👍 / 👎.
| fn key_mut(&mut self, key: &str) -> &mut KeyCharge { | ||
| self.keys.entry(key.to_owned()).or_default() |
There was a problem hiding this comment.
Bound the lifetime of inactive charge records
In a long-running hub with world or program-install churn, every new charge key is retained permanently in this map: neither release nor instance destruction removes it, and the shared budget lives for the process lifetime. In particular, both live installation paths in world_session/service.rs retain the unique per-instance guest-N key, so repeatedly replacing a program in the same world accumulates records even though only one instance remains live. Add bounded retention or lifecycle-aware cleanup for inactive keys, while preserving recent attained service as needed for fairness.
Useful? React with 👍 / 👎.
Problem. F12.10's exit benchmark (
fuel_spin_isolation) misses its target because 15 hostile guests burn synchronously and saturate every core (slice 1, PR #12572): the victim's own service is negligible — its latency is starvation. The placement fix (#12571, guest calls underblock_in_place) was measured on the reference machine by slice 1: ratio unmoved, and the victim's own calls ~20x slower. The remaining lever slice 1's record names is admission — bound how many guest calls burn concurrently, charged per world/account (also the hook the per-account quota criterion needs).Design (
doc/2026-11-22_design_id1067-admission.md). A process-wide guest burn budget in id-worlds (guest_burn): everyWorldInstanceguest call (therun_guest_callfunnel insandbox.rs, all 7 guest methods) acquires a permit after theblock_in_placeconversion, so waiting parks a blocking thread, never a shared worker. Default boundavailable_parallelism - 2(reserve one core for the runtime/actors, one for driver/journal/OS); configured byRuntimeLimits.guest_burn_concurrency(id-caps) /--world-guest-burn-concurrency(id-cli); 0 = auto. Calls past the bound queue, never refuse — the codebase's refusal vocabulary is for requests a world may not make, and refusing the victim's inputs because others burn would invert the fairness criterion; the queue always drains because every admitted call is fuel-bounded. Grants are fair: when a permit frees, the waiter whose charge key has the least attained service (settled fuel, exponentially decayed, 1 s half-life) wins; arrival order breaks ties (FIFO was rejected analytically — the victim would wait ~a full rotation of burns). Charges settle with the actual measured fuel spend; a permit dropped unsettled (panic path) charges its full allowance. Charge key = the world id for store-opened worlds, a unique per-instance label otherwise — a per-account quota can hang off the same counter once world->account ownership is decided on the issue (options (a)-(d) recorded there); this slice does not decide it. Init at instantiate is not admitted (creation-time, once per instance).Reference-machine verdict (laptop, AMD Ryzen 7 7840U, 16 threads). Interleaved pre/post, same command (
--only fuel_spin_isolation), shared fleet load (1-min ~2.1-3.8 at run starts, 5-min ~6 — heavier than slice 1's pair regime). Pre = main9794191ad9bench tree (verified identical to base666424e1cfor the bench/sandbox files), post = this branch (bench binary sha256199d515207698884, verified by hash — the broker pool reuses one filename across worktrees). Full verbatim lines and attribution inpkgs/id/benches/BASELINES.md; the set is appended tobaseline.txt.ratio=4.725, spinning p99 11.420 ms, spinning command mean 1570 us, wake p99 4.428 ms, ack p99 9.902 ms, spins=2505ratio=3.886, spinning p99 9.571 ms, spinning command mean 1980 us, wake p99 3.578 ms, ack p99 8.310 ms, spins=2409,guest_burn_in_flight_max=14, victim waits 613/1805ratio=3.801, spinning p99 8.182 ms, spinning command mean 1403 us, wake p99 3.430 ms, ack p99 6.273 ms, spins=2525, victim waits 727/1805The exit shape is not met, and this PR does not claim it. The ratio improves at matched load but stays above 2, and the victim's spinning command mean does not return to its pre-#12571 level (tens of us). The new budget counters on the profile line attribute why: the bound is the active constraint in every run (in-flight max = the bound), spinner throughput at the default bound is barely dented, and a sizing sweep (bounds 8/10/14 via the new
ID_BENCH_GUEST_BURN_CONCURRENCYbench override) never moved the command mean (1,783-2,637 us across all bounds) while the victim's waits rose as the bound fell (613/1,805 at 14 -> 900/1,805 at 8 and 10). The mean is not permit-wait-bound and not burn-bound: the residual is scheduler contention around the burn path (~800 world spawn/shutdown cycles/s of task and syscall churn on the same runtime, the per-call blocking round trip, ambient fleet load), which a concurrency bound by construction does not govern — that is the hub-scheduler/executor work remaining on #1067.Test evidence.
666424e1c, tests only, laptop):cargo test -p id-worlds --lib --features sandbox two_spinning_guestsfails to compile —cannot find guest_burn in the crate root,no method named set_burn_budget,no method named set_charge_key(6 errors). Behavioral fail-before is slice 1's merged profile record.cargo test -p id-worlds --lib --features sandbox(sandbox:: + guest_burn:: filters) 43 passed / 0 failed — including: bound never exceeded with 8 threads on a budget of 2; charges attributed per key and settled with actual spend (allowance when unsettled); wait-then-run; grant order prefers the least-attained key over an earlier burn-heavy waiter; two spinning guests sharing a budget of one serialize their burns (in-flight high-water mark 1, both charges settled in full); the pre-existing placement test now runs on a dedicated budget of 2 (its oracle is placement, not admission).cargo test -p id-caps175 passed / 0 failed.cargo test -p id-cli --lib743 passed / 0 failed.cargo test -p id-worlds --lib862 passed / 39 failed — all 39 in the known live-network modules (id-worlds live-network tests fail with connect timeouts in the Muse sandbox (environmental) #12488), matching pristine main.many_worlds --quickon the post bench binary reportstarget_met=true(p99 9.399 ms vs the 50 ms target); native programs never enter the admission path.No new dependencies.
What remains on #1067 after this slice: per-account quotas (pending the world->account ownership decision recorded on the issue, options (a)-(d); the per-world charge counter here is the hook), the hub scheduler, slow-client back-pressure, and a fuel-spin profile variant with persistent spinner worlds to separate spawn churn from burn before the next lever is chosen. This PR does not close #1067.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.