Repository navigation
perf(session): coalesce per-turn persistence to ~2 disk-touching writes - #1437
Merged
TheGreatAxios merged 4 commits intoOct 15, 2026
Merged
Conversation
A tool-using turn performed ~6 separate disk-touching persists and one commit per tool batch. response.jsonl folded (nothing read it); tool batches now touch segments only, with the full commit cycle at reply/wait/done terminals; run.json snapshots debounce with an identical-payload skip and flush at every observable state expose; token usage moves to an append-only sidecar so metadata rewrites stop re-hashing it; empty manifest writes converge to removals. On a 60-turn census, disk-touching persists drop to ~3-4 on real turns and wall time 10.2 to 3.9 ms/turn. Crash recovery still rebuilds from on-disk segments (compaction atomicity, crash finalize, exec signal finalize all green); dooms-loop aborts still durably stage turns as before.
Contributor
|
Triage: Fail @TheGreatAxios, please address the following:
|
TheGreatAxios
changed the base branch from
cl-10666-session-perf-cut-per-turn-walks-re-parses-stringifies
to
main
October 15, 2026 20:26
…ence-coalesce-commits-snapshot # Conflicts: # src/session/optimized-context-store.ts
A crash during writeFile left "{not-json" as metadata.json. load() parsed
that document before the token-usage sidecar, so the catch assigned
emptyMetadata() and dropped a valid sidecar line. Sidecar usage is read
even when the document throws. metadata.json is published by renaming a
temp file in the same directory, so the published name is never partial.
Collaborator
Author
|
Independent perf verification for this PR (measure-only lane, no source touched). Method: same-workload, same-host probes on both trees (before = pre-merge parent, after =
No action needed — the coalescing measures as claimed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
response.jsonlis folded into the turns store (a repo-wide consumer audit found nothing reads it; legacy trees keep staging it in vendor commits). Tool-batch commits relax to segments-only staging with the full commit cycle deferred to reply/wait/done/suspend terminals (vendored reactor patch, ledgered, superseding the per-batch checkpoint entry).run.jsonsnapshots debounce (~5s) with an identical-payload skip; heartbeats bypass the skip so a quiet long-running inference keeps its mtime liveness for any external reader; flushes wired at every observable expose (interrupt rebuild, session rotation, finalize, exec terminal). Token usage moves to an append-only sidecar keyed to the turn frontier, with load precedence sidecar > legacy metadata > empty and torn-tail drop on crash. Empty manifest writes converge to removals.scripts/turn-persistence-census.ts).Verification
bun run checkexit 0: 8,959 pass / 0 fail across 581 files.Fixes CL-10667