perf(decofile): make in-commit blocks.gen.json regen cache-aware - #6707
Open
guitavano wants to merge 1 commit into
Open
perf(decofile): make in-commit blocks.gen.json regen cache-aware#6707guitavano wants to merge 1 commit into
guitavano wants to merge 1 commit into
Conversation
The decofile commit path regenerates a committed .deco/blocks.gen.json inside every save commit. It fetched every unchanged block via client.getBlobText (no disk cache) in an unbounded Promise.all — on a large repo (e.g. ~325 blocks) that is hundreds of uncached GitHub round trips per save, adding several seconds of latency before the preview can load. Align the regen with the read path (resolveSnapshot): - Read unchanged blocks disk-cache-first via a shared getBlockText, with bounded concurrency (BLOB_FETCH_CONCURRENCY). The editor's read just primed those blobs, so a same-replica save is mostly cache hits; a cold replica fetches at most N at a time instead of stampeding GitHub's abuse limiter. - After the commit lands, prime the merged-doc cache (primeMergedSnapshot) with the just-computed document — byte-identical to what resolveSnapshot produces at that sha — so the preview read immediately after a save is a disk hit rather than a fresh tree read + re-merge. Only affects repos that commit blocks.gen.json; gitignored repos (the common case) never enter the regen branch and are unchanged. Adds an e2e test asserting the regen replaces a stale committed artifact with a full re-merge of the block set. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
The decofile commit path (
commit-coalescer.ts) regenerates a committed.deco/blocks.gen.jsoninside every save commit. Today it re-fetches every unchanged block viaclient.getBlobText(bypassing the disk cache) in an unboundedPromise.all. On a large repo (e.g. Granado, ~325 blocks) that's hundreds of uncached GitHub round-trips per save — several seconds of latency before the preview can even load, since the preview reads by commit sha.This is the general-case (option "a") counterpart to per-repo untracking of the artifact: it helps every repo that keeps
blocks.gen.jsoncommitted.Change
Align the in-commit regen with the read path (
resolveSnapshot):getBlockText(client, sha)tries the disk cache before GitHub and writes through on a miss; the loop usesmapBounded(..., BLOB_FETCH_CONCURRENCY). The editor's read right before a save already primed those blobs, so a same-replica save is mostly cache hits; a cold replica fetches at mostNat a time instead of stampeding GitHub's abuse limiter (the exact reason the read path is already bounded).primeMergedSnapshot(...)stores the just-computed document under the new sha's merged-doc key — byte-identical to whatresolveSnapshotproduces at that sha (samemergeBlocks, same sort) — so the preview read immediately after a save is a disk hit instead of a fresh tree read + re-merge.Scope / tradeoff
blocks.gen.jsonenter the regen branch; gitignored repos (the common case) are untouched.Testing
decofile-api.spec.ts): seeds a repo with a stale committedblocks.gen.json(missing a block, pre-edit value), PATCHes a block, and asserts the artifact was fully re-merged (edited + untouched blocks, keys sorted by filename). This branch had zero e2e coverage before. Passing locally against the real server + GitHub stub (1 passed (15.4s)).bun run check(apps/api + packages/e2e) and existing decofile unit tests pass;bun run fmtclean.🤖 Generated with Claude Code
Summary by cubic
Speeds up saves in repos that commit
.deco/blocks.gen.jsonby making the in-commit regeneration disk-cache-first and bounded, instead of re-fetching every unchanged block from GitHub in an unboundedPromise.all.getBlockTextpath withBLOB_FETCH_CONCURRENCYconcurrency, mirroring the read path.Written for commit f92ea96. Summary will update on new commits.