Skip to content

id(world): shared sync epochs for journal appends (#557) — DRAFT, negative result, do not merge - #12496

Draft
dezren39 wants to merge 1 commit into
mainfrom
archer-lane-a/557-world-p99
Draft

dezren39 wants to merge 1 commit into
mainfrom
archer-lane-a/557-world-p99

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

DRAFT — DO NOT MERGE. This is a negative result, recorded as a PR so the evidence is reviewable.

One slice attempt for the #557 F12.12 p99 criterion, aimed at the input/ack cost in felix's 2026-11-22 profile (PR #12471): after group commit (#8239), durability-before-ack still costs one sync_data per journal append, and at 100 worlds × 20 inputs/s the filesystem's aggregate sync rate was the suspected cap.

This branch routes FileJournal appends through a per-filesystem SyncGate (crates/id-worlds/src/world_store.rs): the writer writes its bytes, registers the next epoch, and waits until a syncfs that started after its registration completes; a failed or unavailable gate sync falls back to the writer's own sync_data, which decides the append exactly as before. The mechanism is correct — the measurements below say syncfs is the wrong primitive on every filesystem measurable from the sandbox lane.

Evidence

Tests (all green):

  • New oracle tests in world_store: a waiter is released only by a sync that starts after it registered (latch-controlled sync); 256 concurrent waits settle in ≤ 32 shared syncs; a failed sync releases the waiter with an error, never a false durable; appends through the gated writer land exactly and in order.
  • cargo test --release -p id-worlds --lib via fleet-run on this branch: 873 passed, 0 failed — https://github.com/developing-today/fleet/actions/runs/45009277444
  • Same suite in the Muse sandbox: 834 passed, 39 failed — every failure an iroh peer-connect timeout in *_net modules ("connect to world host: timed out"; sandbox UDP is blocked). The fleet run of the identical suite is 873/873, so those are environmental.

Harness — cargo bench --bench world_bench -- --only journal_append_fsync and --only many_worlds:

Fleet runner (same machine class, main vs this branch):

run fsync median many_worlds p99 input_ack p99 completed target
main (45009273393) 111.485 µs 1.884 ms 0.380 ms 2000.0/s met
this branch (45009269723) 276.317 µs 2.508 ms 1.148 ms 1999.8/s met

Muse sandbox (btrfs home volume, 1.5 shared vCPU, TMPDIR on the home disk; this machine is CPU-quota-bound at this load, so its many_worlds rates mix CPU contention with sync cost — the microbench delta is the clean signal):

run fsync median many_worlds p99 input_ack p99 completed target
main 15,881 µs 107,424 ms 2,594 ms 170.2/s not met
this branch 19,980 µs 168,708 ms 4,015 ms 110.6/s not met

Reading: one syncfs costs ~2.5× one fdatasync on the fleet filesystem and ~1.26× on the sandbox btrfs (where it also flushes a large, busy home volume and burns contended CPU). Sharing syncs only pays when the shared sync is cheaper than the sum it replaces; on both filesystems measured here it is not. The one machine where the criterion actually fails — the reference laptop (ext4) — is felix's live thread on #557 and cannot be measured from this lane; syncfs is unpriced there.

Merge Danger

Not mergeable on this evidence: it regresses the journal microbench on both measured filesystems. Kept as a draft for the record; the durability design (registration-after-write, covering-sync ordering, fallback-decides) and its oracle tests are sound and reusable if a cheaper shared-sync primitive is ever priced on the target machine. Baseline files are untouched; the recorded reference baseline on #557 remains felix's thread.


Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Durability-before-ack cost one sync_data per journal append. At the
F12.12 load (100 active worlds x 20 inputs/s = 2,000 syncs/s),
concurrent fdatasync across 100 journal files serializes in the
filesystem well below the offered rate, so the sync layer — not
service time — caps throughput and the backlog lands in the
many-worlds p99 (felix profile, 2026-11-22: input/ack p99 379 ms on
the reference laptop; sandbox before-run: 170 of 2,000 offered
inputs/s completed).

FileJournal writers now prove durability through a per-filesystem
SyncGate: the writer writes its bytes, registers the next epoch, and
waits for a syncfs that started after its registration — one sync
covers every pending append on the filesystem, and syncs run
back-to-back under load. A failed or unavailable gate sync settles
the epoch as failed and the writer falls back to its own sync_data,
so the append's result is decided exactly as before. Non-Linux
builds keep the per-append sync_data path unchanged.

Oracles (new tests, world_store): a waiter is released only by a
sync that starts after it registered (latch-controlled sync); 256
concurrent waits settle in a handful of shared syncs; a failed sync
releases the waiter with an error, never a false durable; appends
through the gated writer land exactly and in order. Existing
world_store tests (49) stay green.
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

This branch has not been deployed

No deployments
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