GeezerVison is showing github.com — id-worlds: guest-burn admission - bound concurrent guest burns, charged per world (#1067 slice 2) by dezren39 · Pull Request #12615 · developing-today/code
Conversation
dezren39
commented
Nov 22, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
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 under block_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): every WorldInstance guest call (the run_guest_call funnel in sandbox.rs, all 7 guest methods) acquires a permit after the block_in_place conversion, so waiting parks a blocking thread, never a shared worker. Default bound available_parallelism - 2 (reserve one core for the runtime/actors, one for driver/journal/OS); configured by RuntimeLimits.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 = main 9794191ad9 bench tree (verified identical to base 666424e1c for the bench/sandbox files), post = this branch (bench binary sha256 199d515207698884, verified by hash — the broker pool reuses one filename across worktrees). Full verbatim lines and attribution in pkgs/id/benches/BASELINES.md; the set is appended to baseline.txt.
- pre:
ratio=4.725, spinning p99 11.420 ms, spinning command mean 1570 us, wake p99 4.428 ms, ack p99 9.902 ms, spins=2505
- post A:
ratio=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/1805
- post B:
ratio=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/1805
The 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_CONCURRENCY bench 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.
- Fail-before (scratch worktree at base
666424e1c, tests only, laptop): cargo test -p id-worlds --lib --features sandbox two_spinning_guests fails 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.
- Laptop, this branch:
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-caps 175 passed / 0 failed. cargo test -p id-cli --lib 743 passed / 0 failed.
- Sandbox: full
cargo test -p id-worlds --lib 862 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.
- Regression spot-check (laptop):
many_worlds --quick on the post bench binary reports target_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-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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 reached
You'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.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6ca42dc9-4832-4e46-b4f3-34adefdb0932
Commits
-
Reviewing files that changed from the base of the PR and between 16ffdfd and 1e2c788.
Files selected for processing: 11
-
doc/2026-11-22_design_id1067-admission.md
pkgs/id/benches/BASELINES.md
pkgs/id/benches/baseline.txt
pkgs/id/benches/world_bench.rs
pkgs/id/crates/id-caps/src/world_limits.rs
pkgs/id/crates/id-cli/src/cli/world.rs
pkgs/id/crates/id-worlds/src/guest_burn.rs
pkgs/id/crates/id-worlds/src/lib.rs
pkgs/id/crates/id-worlds/src/sandbox.rs
pkgs/id/crates/id-worlds/src/world_store.rs
pkgs/id/src/lib.rs
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-22T15:57:26.179617Z |
1e2c788 |
PR opened |
ℹ️ 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" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 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".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+196
to
+198
|
|
static CONFIGURED: OnceLock<Arc<GuestBurnBudget>> = OnceLock::new();
|
|
|
CONFIGURED
|
|
|
.get_or_init(|| Arc::new(Self::new(max_concurrent)))
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+237
to
+239
|
|
state.waiters.retain(|waiter| waiter.ticket != ticket);
|
|
|
Self::admit(&mut state, key);
|
|
|
break;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+126
to
+127
|
|
fn key_mut(&mut self, key: &str) -> &mut KeyCharge {
|
|
|
self.keys.entry(key.to_owned()).or_default()
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|