perf(context): batch blob reads + single-flight the workspace build#12
Merged
Conversation
Implement the two deferred review items by making the discovery build async: - Batched reads (#2): a build now reads every needed blob (conventions + source files) in ONE `git cat-file --batch` process instead of one `git show` per file. defaultGitRunner switches to spawn (async, binary-safe, feeds refs on stdin) and parseBatch frames the records by byte size. This removes the N-subprocess fan-out and the fixed maxBuffer ceiling. - Single-flight (#5): getContextPack is now genuinely async, so concurrent first-callers on the same HEAD SHA share one in-flight build instead of both running it. (Previously moot because _build was synchronous.) A source file missing from the batch is skipped, not fatal. parseBatch and defaultGitRunner are unit-tested directly (present/missing/truncated/multi-byte; exit-code and spawn-error paths). Docs updated to reflect the batched/async read. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Implements the two items deferred from the last review — by making the discovery build async.
#2 — one process instead of N
A build now reads all needed blobs (conventions + up to 200 source files) in a single
git cat-file --batchprocess, instead of onegit showper file.defaultGitRunnerswitches fromexecFileSynctospawn(async, binary-safe, feeds refs on stdin) — also removes the fixed 1 MB/64 MBmaxBufferceiling.parseBatchframes the records by byte size (multi-byte safe); a missing blob is skipped, not fatal.#5 — single-flight
getContextPackis now genuinely async, so concurrent first-callers on the sameHEADSHA share one in-flight build rather than both running it. (Previously moot because_buildwas synchronous — now real and tested.)Tests
parseBatchanddefaultGitRunnerare unit-tested directly (present / missing / truncated / multi-byte; non-zero exit; spawn error), plus single-flight dedup, the empty-batch short-circuit, and the default spawn-backed path. Docs updated to reflect batched/async reads.Gates
typecheck✅ ·lint✅ ·test:coverage✅ (416 tests, 100%) ·build✅.🤖 Generated with Claude Code