Repository navigation
Description
Summary
Every commit does writeln + flush + sync_data() (storage.rs append_line) and one model step takes about 4.8 commits. This is the durability guarantee that makes crash-resume (E5) work, and it is correct. The cost is real though: on the fleet host a 200-byte append + fdatasync measures p50 4.95 ms, p95 14.3 ms, max 38.5 ms (300 samples).
Measured (develop @ 438ad0d, instant local mock, 25 sequential steps)
- sessions on the overlay disk: wall p50 1.57 s
- sessions on tmpfs (no real fsync): 0.45 s
- so the fsync-dependent share is about 43 ms per step on this host (4.8 commits x p50 4.95 ms is about 24 ms; the tail explains the rest)
- nca 0.5.5 (JSON snapshot at checkpoints plus an events log; no explicit fsync in
session_store.rs/supervisor.rs): 0.55 s
A real model step is 1-9 s, so this does not matter for chat; it matters for long missions with many fast read-only tools.
A 10-tool-step session produced 54 physical lines (1 header + 53 commit lines) for 11 provider steps, i.e. about 4.8 commits per step: intent, state transitions, settlement, usage, plus the final-answer bookkeeping.
Options (measure before choosing; durability must not regress)
- Coalesce the commits that are logically one atomic unit into a single line. The format already supports a commit as one JSON array line (one physical line = one transaction). Fewer lines per step = fewer fsyncs with identical crash semantics.
- Relax the fsync for entries that are pure read-only effects with
ReplaySafety::Idempotent(replay is safe anyway) while keeping it for Write/Destructive intents and settlements. Needs a design note: what exactly may be lost on power failure, and does the E5 crash matrix still hold? - Group commit across one batch (see harness: only the first tool call of a response runs — measured cost of the 'no parallel tool calls' non-goal on the real fleet model #480). Blocked unless harness: only the first tool call of a response runs — measured cost of the 'no parallel tool calls' non-goal on the real fleet model #480 decides to revisit the sequential-batch non-goal (
docs/prd.md:69,docs/architecture.md:169).
Non-goals: dropping sync_data() globally; changing the on-disk format.
Acceptance
- Design note choosing an option, with the crash matrix re-run (E5 golden, SIGKILL harness).
- Before/after numbers on the same harness, same host.
- No change to torn-tail repair semantics.
Found by
Head-to-head against nca 0.5.5; storage constants read from source, numbers measured live.
Activity
[-]storage: ~4.8 fsync'd commits per model step \u2014 measure and decide what can be coalesced (design note)[/-][+]storage: ~4.8 fsync'd commits per model step — measure and decide what can be coalesced (design note)[/+]