Repository navigation
perf(session): cut per-turn store walks, re-parses and stringifies - #1434
Merged
TheGreatAxios merged 2 commits intoOct 15, 2026
Merged
TheGreatAxios merged 2 commits into
TheGreatAxios merged 2 commits into
Conversation
A 200-turn simulation dropped 139 to 124 fs ops per turn (access probes 2697 to 3) and wall median ~13%. commit() now surveys the worktree once instead of stat-probing every candidate segment; a per-store turns cache with per-segment stat fingerprints plus explicit mutation-site invalidation loads each segment at most once, so load/ readLiveTurns/prompt-write parse once per content instead of three times. contentPrefixLength/promptEqualsLiveTurns memoize turn JSON instead of stringifying full history; the well-formedness prefix scan is a single forward pass instead of O(E^2); readAt reads a commit-time segment manifest and parallel blob reads, degrading to the ref-walk when the manifest is absent or torn; attachment blob reads dedupe; aged-image markers prefilter before regex; anthropic cache prompt aggregates one forward scan; compaction identities are cached per tool_call block. Invalidation is strictly wider than the reads it replaced: mutation sites and failed-commit restores drop the caches; corrupt manifests degrade to the walk.
Contributor
|
Superseded by the comment below. |
Contributor
|
Superseded by the comment below. |
Contributor
|
Triage: Pass No changes needed from you. A maintainer will review this pull request. |
TheGreatAxios
changed the base branch from
cl-10654-isomorphic-git-1442-batch-remove-hot-path-perf
to
main
October 15, 2026 19:47
…-cut-per-turn-walks-re-parses-stringifies # Conflicts: # src/session/attachment-store.ts
Collaborator
Author
|
Independent perf verification for this PR (measure-only lane, no source touched). Method: the commit's own harness
No prompt/policy retune indicated — the optimization measures exactly 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
commit()(fs-op census: 139 → 124 ops/turn on a 200-turn simulation;fs.access2,697 → 3 per run); a per-store turns cache with per-segment stat fingerprints + explicit mutation-site invalidation parses each segment once (the three separate full-history parses per turn become one shared generation, parsing only changed/new segments);contentPrefixLength/promptEqualsLiveTurnsmemoize turn JSON instead of re-stringifying full history; the well-formedness prefix check becomes a single forward pass (O(E²) → O(E), equivalence probed on 50,000 randomized interleavings before ship);readAtresolves a commit-timesegment-manifest.jsonand parallel-reads segment blobs, degrading to the old ref-tree walk on missing/torn/foreign manifests; attachment blob reads dedupe per id; aged-image markers prefilter before regex; the anthropic-cache prompt builds its tool-name/boundary maps in one forward scan; compaction call identities are cached per persisted block.scripts/context-store-perf.ts, standalone; fs-op census deterministic, wall noisy).Verification
bun run checkexit 0: 8,945 pass / 0 fail across 580 files; src/session suites 62 store tests (4 new) + 7 attachment tests (2 new) green.Fixes CL-10666