Skip to content

id(world): F12.12 many worlds per node: 1,000 idle / 100 active with a per-world memory budget #557

Open

Description

@dezren39

What and why

Lazy open, idle eviction with checkpoint and a bounded memory budget per world, measured against 1,000 idle and 100 active (20 ev/s, p99 < 50 ms) targets with the F11.8 harness. Lazy open, eviction and per-guest memory caps exist, but nobody has measured the targets and a world's total memory is not bounded.

Source

Current status

Partial. Mechanisms exist from Phase 9/10: pkgs/id/src/world_hub.rs:7-15 (lazy single-flight open, session and open-world ceilings, idle eviction), and a per-guest linear memory cap of 16 MiB (pkgs/id/src/sandbox.rs:25-36). The per-world total memory budget with refusal tests landed in #4628. The F11.8 many-world measurement now exists; its p99 is 5,650.792 ms versus the 50 ms target, so that performance criterion remains open. The checkpoint/eviction/reopen integrity assertion passed for all 100 active worlds.

Acceptance criteria

  • A per-world total memory budget is enforced, with refusal tests
  • 1,000 idle and 100 active worlds (20 ev/s each, p99 < 50 ms) are measured with the F11.8 harness and the results recorded (measured p99: 5,650.792 ms; target missed)
  • Idle eviction checkpoints and reopens without loss under that load

Size

L

Prerequisites

Activity

  1. added
    kind/featureNew feature or capability request
    source/humanFiled directly by a human
    priority/normalOrdinary priority (the default)
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Oct 26, 2026
  2. dezren39 commented on Oct 26, 2026

    @dezren39
    MemberAuthor

    Intake review

    Fleet-monitor intake pass (2026-10-26). Body already carries a full ## Acceptance criteria section, so this pass is label normalization plus a liveness check — no body edit.

    Verified live on main e3467560 (2026-10-26): no per-world total memory budget exists — git grep -i 'memory_budget\|per-world.*memory' origin/main -- pkgs/id/src finds nothing; the per-guest linear-memory cap the body cites is still the only memory bound. The measurement half is also untouched (no harness run recorded). Still live; the body's "Partial" status assessment still holds.

    Related: prerequisite #539 (F11.8 benchmark harness with committed baselines) is still open and unenriched — the 1,000-idle/100-active measurement cannot be recorded without it. The metrics from #553 would make the budget observable once enforced.

    Risks / notes: a per-world budget needs a defined refusal behavior when a world exceeds it (refuse new allocations vs. evict vs. poison) — that semantic choice should be made in the implementation plan, mirroring how the sandbox handles guest memory exhaustion.

    Suggested approach: define and enforce the per-world budget with refusal tests first (verifiable without the harness), then run the scale measurement once #539's harness exists and record the numbers on this issue.

  3. added
    nextOrg Project gate: queued next — orchestrator adds to the board
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Oct 27, 2026
  4. 405 remaining items

  5. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Summary: Sandbox lane A4 — Slice 2 (fdatasync group commit at the journal writer) STOPPED at Phase 1, per the slice's own measurement gate: under the full many_worlds (F12.12) bench profile, same-journal append queueing is zero — no sync ever started with another append waiting behind it, and no append ever arrived during another append's sync. Writer-level group commit would form a batch of exactly 1 every time. Phase 2 was not run, no oracle tests were written (their premise — queued appends to coalesce — is what Phase 1 refuted), and no PR is opened.
    Worker: archer sandbox lane A4
    Status: progress (slice measured, closed at Phase 1)
    Supersedes: my own picked-up note of 2026-11-22 on this issue.
    Issue state checked: 2026-11-22 — read the issue and the lane A / A2 / A3 evidence comments; audit and measurement on main 44bdc15 (includes felix's #12499).

    Method

    Phase 1 instrumentation (lane branch archer-lane-a4/557-group-commit, commit b6db33c — measurement scaffolding only, NOT proposed for merge): journal_writer_loop (world_store.rs) drains its channel into a local queue — order preserved, every request still handled exactly as before (one write+sync+reply per append; local world_store tests 45/45 with the change) — and samples two depths per append, printed per writer at exit under ID_JOURNAL_WRITER_STATS:

    • queued_behind: appends already waiting when an append's write+sync starts. This is the group-commit batch size minus one: a drain-all-then-one-sync writer forms batches of 1 + queued_behind.
    • waiting_after_sync: appends that arrived while that write+sync ran (sampled immediately after the reply).

    Run on the fleet runner, full F12.12 profile plus the single-journal control cell: https://github.com/developing-today/fleet/actions/runs/45016568830

    Numbers

    Bench profile for the same run: 1,000 idle + 100 active worlds, 20 ev/s/world, 10 s, 20,000/20,000 commands acked (1,999.9 ev/s), end-to-end p99 3.638 ms, target_met=true (runner storage, as established). Actor-level profile: journal_appends=20,200, queue_depth_max=0 — felix's #8239 actor drain also never found a second input to coalesce.

    Writer-level, aggregated over all 1,205 writers and 31,405 appends in the run:

    writer class writers appends appends with queued_behind ≥ 1 max queued_behind syncs with an append waiting after
    many_worlds active 100 204 each 0 0 0
    many_worlds idle 1,000 1 each 0 0 0
    journal_append_fsync control 5 2,001 each 0 0 10 total, max 1

    The control cell's 10 events are the tight single-producer loop's next sequential append landing in the reply window after a sync — one append, nothing behind it; coalescing it would mean delaying the current ack, not batching. Even there, no sync ever started with work queued behind it.

    Why it is structural, not incidental

    The writer's only producer is the world actor, through &mut dyn WorldJournal; JournalWriter::append blocks the caller until the writer replies, and the actor handles one command (or one #8239 batch) at a time, persist-before-ack. Per-journal append concurrency is therefore 1 by construction, and at F12.12 pacing (one input per world per 50 ms, each awaited) the arrival gap dwarfs the ~0.6 ms mean append latency. The batching that can exist already exists one level up — the #8239 actor drain into append_batch (one sync per batch) — and at this load it never fires either (queue_depth_max=0).

    Conclusion

    Syncs-per-append at the journal is already exactly 1, with measured batching headroom of 0. Slice 2's remaining lever is closed on the same evidence standard as Slice 1 (Lane A3) and syncfs (Lanes A/A2): there is nothing left to coalesce. What remains for the criterion on the reference laptop is sync COST (ext4 fdatasync latency, Lane A2's ~5.3 ms median under load) and wake latency — felix's idle-baseline thread, which this lane did not touch. The criterion itself is judged on the laptop against that baseline; nothing here closes or moves it.

    No code merged, no PR opened. The instrumentation commit stays on the lane branch as the measurement record; if a future profile ever suspects writer queueing, it re-runs as-is under ID_JOURNAL_WRITER_STATS=1.

    — archer-lane-a4

  6. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Progress from felix: Win A (inline journal write+sync) implemented; bench rebuild in progress

  7. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Progress from felix: Win A committed (ee371a0); running lib tests and a load-matched baseline pair for the PR table

  8. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Progress from felix: tests + load-matched baseline build still running under contention

  9. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Verification note — xaltha seat, no claim taken (2026-11-22).

    Picked up #557 from this host's shortlist and revalidated before starting, per the one-slice rule. State found:

    No slice taken from this seat: the named next steps (felix's Win A PR, then the unloaded laptop re-run against his idle baseline) are felix's and in flight. Starting a parallel slice would duplicate a live claim. This seat moves to the next shortlist item; #557's remainder stays with felix's lane until his run lands or the claim goes stale.

  10. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Second-pass timing review done (per the direction to look for any other obvious wins regardless of the target). PR #12552 is open for review — not merged.

    Landed (one clean win): the journal no longer hands each append to a dedicated writer thread over a channel with a rendezvous reply. The writer's queue was empty at every dequeue by construction — the journal's only producer is its owning actor, rendezvous-blocked until the in-flight append is durable — so each append paid a channel send, a thread wake, and a reply wake around the same write+sync, plus one thread per world. FileJournal now owns its File and writes inline under the same block_in_place guard as the first fix. No durability/ordering change: ack still follows the sync that covers the entry.

    Measurement (sandbox, TMPDIR on btrfs, full size): append-mean stayed in one band across runs (baseline 52,713 µs; inline 47,713–58,407 µs) while latency percentiles swung ±2× with ambient sandbox load — the delta is not measurable in this venue, and no run shows a regression from it. It is offered as a structural simplification; full table in the PR and in BASELINES.md.

    Audited, no change: the sync call is already exactly one write_all + one sync_data per append; writer-side batching is structurally impossible (same argument as above); remaining hops are inherent to the actor model; the one pure waste found — a second full entry serialization per append for the replication broadcast, even with zero receivers — is bounded by recorded data to inside the noise (laptop run: command mean 25,692 µs vs journal append mean 25,784 µs) and is recorded in the PR as evaluated-and-rejected churn.

    Design question left open (not implemented): input_ack waits for the journal sync in both the single and batch paths — the documented WorldJournal contract. On the post-fix laptop run, input_ack_p50 18.892 ms vs journal append mean 25.784 ms: the ack is the sync wait. Any batched/async ack changes durability semantics and needs an owner decision.

    Tests: cargo test -p id-worlds --lib 836 passed / 40 failed — 39 are the #12488 network-timeout class; the one other failure is a pre-existing stale MAX_JOURNAL_VERSION pin from the kv merge, filed as #12541. Zero failures from this change.

    The issue stays open: the 50 ms p99 target is still unmet, and the remaining tail is the sync itself plus wake scheduling under load.

  11. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: free). Second-pass review done: PR #12552 open (inline journal write, measured neutral in sandbox venue, no regression); seam audit + design question recorded on the issue. Felix reviews/merges.

  12. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: merged
    by: agent felix (kind muse, Muse sandbox seat; queue fallback claim, worker felix)
    at: 2026-11-22

    Second-pass review landed: #12552 (merged).

    Per-seam verdicts are in the PR; the one landed win is structural: the per-world journal writer thread is gone. The writer's queue could never form (the owning actor is the sole producer and rendezvous-blocks until the in-flight append is durable — the same reason queue_depth_max reads 0 in every profile), so the thread was pure overhead: one channel send, one thread wake, and one reply wake per append, plus a thread per world. FileJournal now writes inline (same write_all + sync_data under the block_in_place guard from the first fix). No durability or ordering change. The sandbox venue could not measure a delta (ambient load swung percentiles ±2x while mechanism metrics stayed in one band) and showed no regression; the change stands on the construction argument and the hop count. Everything else reviewed was either already minimal (the sync is a single fdatasync-equivalent), immaterial (the duplicate serialization for the replication broadcast — recorded in the PR for a future CPU-bound profile), or a semantics question (below).

    Design question left open for Drewry, deliberately not implemented: input_ack waits for the journal sync in both paths — it is the documented WorldJournal contract ("acknowledged history must never get ahead of durable history"), and the laptop numbers say the ack essentially IS the sync wait (input_ack_p50 18.892 ms vs journal mean 25.784 ms). An async or batched ack would be a durability-semantics change.

    #557 remains open for the unloaded laptop re-run and that ack decision.

  13. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    decision:v1
    by: Drewry (via Felix, main chat)
    at: 2026-11-22

    input_ack: async/batched acknowledgement is APPROVED as SELECTABLE MODES — not a default flip. The durability contract stays the default; async/batched modes are opt-in per configuration, with the tradeoffs documented where the modes are defined. The fsync/syncfs group-commit tradeoffs (the evaluated-and-rejected Fix 2 line) must be discussed in the same documentation pass, so the record shows all three durability levers side by side. The unloaded laptop re-run remains outstanding as the measurement baseline.

  14. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.)

  15. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: implementing the selectable input_ack modes per Drewry's 2026-11-22 decision (comment 7087900634) — sync default unchanged, async/batched opt-in per configuration, tradeoff documentation in the same pass. Worktree felix/557-ack-modes.

  16. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress from felix: ack modes implemented on branch felix/557-ack-modes (design doc + JournalAckMode + FileJournal modes + WorldLimits plumbing + tests + BASELINES note). Laptop test run queued on the fleet build lock; PR follows once the journal suites pass.

  17. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: slice-landed
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-23

    Landed for review: #12746 — selectable journal ack modes, per Drewry's 2026-11-22 decision (comment 7087900634). NOT merged; Felix reviews.

    What it is: JournalAckMode on the journal — Sync (default; the documented durability-before-ack contract, byte-for-byte the old behaviour), Batched (one sync per 64 appends; loss bounded to the unsynced tail), Async (no sync on the ack path; durability at sync points only). Selected per world via WorldLimits::journal_ack_mode, plumbed through open_world to FileJournal::open_with_ack_mode; observable via WorldJournal::ack_mode() and FileJournal::unsynced_appends(). Tradeoffs for all three levers (ack timing, the fdatasync primitive, and the rejected syncfs/fdatasync group-commit axis) are documented on the enum where the modes are defined and in the design record doc/2026-11-23T00-24-00Z_design_journal_ack_modes/. Transactions and compaction stay full sync points in every mode; the journal format and recovery scan are unchanged, so a mode switch on reopen replays identically. No new dependencies.

    Evidence (laptop, fleet-build-lock): fail-before — the six new tests alone on pristine origin/main fail to compile (26 errors, the whole mode surface missing). Pass-after — cargo test -p id-worlds --lib journal_ 66 passed / 0 failed (incl. the five new mode tests); world_store:: 51 passed / 0 failed; world_limits_default 1 passed; rustfmt clean. Clippy is environment-blocked on the laptop's shared target dir (E0514, the same failure the #1062 lane recorded); no new warnings touch the changed code.

    What remains on #557, unchanged by this slice: the unloaded laptop re-run of the many-worlds harness is still the deciding measurement and still outstanding — the modes are opt-in and the default path is untouched, so no existing baseline moves. A BASELINES.md section records the landing with no new number, per the decision's terms.

  18. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Released by felix (outcome: free). Selectable ack modes landed as PR #12746 (unmerged, for Felix's review): JournalAckMode sync/batched/async, WorldLimits plumbing, design doc, 6 tests green on laptop; #557 stays open for the unloaded re-run.

  19. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: slice merged
    by: agent felix (kind muse, Muse sandbox seat)
    at: 2026-11-22

    Merged: PR #12746 (2026-11-23T00:58:39Z) — selectable journal ack modes, implementing Drewry's 2026-11-22 ruling (comment 7087900634). Sync remains the default with byte-for-byte the old contract; Batched (one sync_data per 64 appends, loss bounded to the unsynced tail) and Async (durability only at sync points) are opt-in per world via WorldLimits::journal_ack_mode. The running mode is observable (ack_mode(), unsynced_appends() — always 0 in Sync), journal bytes and recovery are mode-independent (pinned by the cross-mode reopen test), and transactions/compaction stay full sync points in every mode. The tradeoff documentation sits on the enum and in doc/2026-11-23T00-24-00Z_design_journal_ack_modes/, with all three durability levers side by side including the fsync/syncfs group-commit axis (measured-and-rejected numbers carried from the Fix 2 record). Evidence: fail-before compile failure on pristine main (26 errors, surface missing); 66/66 journal tests + 51/51 world_store on the laptop under the build lock. No new dependencies.

    Still outstanding on #557, unchanged: the unloaded laptop re-run of the many-worlds harness — the deciding measurement. No baseline number moves until a world runs in a relaxed mode and is measured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/lLarge: multi-day or open-ended; expect staged check-insenhancementNew feature or requestepic/id-programReprioritization program epic (2026-11-12)kind/featureNew feature or capability requestmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedmode/onlineFully doable remotely: design, config, code, cloudnowOrg Project gate: active priority — orchestrator adds to the boardpriority/normalOrdinary priority (the default)queue/queuedHas a queued queue tasksource/humanFiled directly by a humanstatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions