perf(snapshot): serialize once in writeSnapshotDual, byte-copy to the cache#655
Closed
justrach wants to merge 1 commit into
Closed
perf(snapshot): serialize once in writeSnapshotDual, byte-copy to the cache#655justrach wants to merge 1 commit into
justrach wants to merge 1 commit into
Conversation
… cache writeSnapshotDual ran the full writeSnapshot serialization twice — once for the project-root snapshot and again for ~/.codedb/projects/<hash>/: two lock acquisitions, two content-hash passes, and (after releaseContents) two whole-repo disk reads. A finished snapshot is a plain file: copy it to the cache path instead (own tmp + rename, same crash-safety contract). The two copies are now byte-identical, where two serializations could diverge between lock acquisitions. writeProjectCacheSnapshot keeps its full-serialization behavior for its standalone callers (bootstrap CLI fallback, tests). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Superseded by #652 (landed while this was in review — same change, convergent implementations from the same write-path survey). Numbers from this PR's validation transfer: 92MB corpus snapshot 0.78s → 0.72s median, cache copy byte-identical (sha256-verified). |
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.
Round-2 item 3 (snapshot write-path survey — the write path had never had a perf pass; load got 3× in #524).
What
writeSnapshotDualran the fullwriteSnapshotserialization twice — project-root snapshot, then~/.codedb/projects/<hash>/: two shared-lock acquisitions, two per-file content-hash passes, two tree/outline serializations, and — afterreleaseContents()(the normal post-scan server state, #519) — two whole-repo disk reads. A finished snapshot is a plain file: serialize once, then byte-copy to the cache path with the same tmp-random-suffix + rename contract.writeProjectCacheSnapshotkeeps full-serialization behavior for its standalone callers (bootstrap CLI fallback, tests).Correctness
zig build test: 23/23 steps, 869/873 (4 platform skips). e2e: 20/20.Numbers
codedb <root> snapshot, 3 runs each: 0.78s → 0.72s median — the eliminated second serialization (~60ms here) scales with snapshot size, and grows further on released-contents servers where it also paid the whole-repo re-read.🤖 Generated with Claude Code