bootstrap: stream commit-graph fetch to bound planning memory#61
Merged
Conversation
Replace the per-branch memory.NewStorage() planning fetch with a streaming extractor that pulls only (commit -> parent hashes) tuples from the tree:0-filtered pack. Previously, bootstrap planning materialized the entire commit set (~1.4M decoded commits for linux, ~5 GiB) just to read each commit's ParentHashes. The new path reads the pack incrementally, extracting parents from each commit as it arrives and discarding the bytes; a bounded LRU keeps recent objects in memory only long enough to resolve deltas. Planning then walks the resulting parents map directly. Measured against `replicate --all-refs https://github.com/torvalds/linux.git` into a local git-http-backend target: before after delta Peak Go heap (inuse) 5.42 GiB 1.47 GiB -73% Peak OS RSS 5.69 GiB 1.63 GiB -71% Wall time (4 GiB batches) 32m 04s 19m 09s -40% Refs pushed 2862/2862 2862/2862 same
ede27fd to
f5cc40c
Compare
6a511ec to
ef72e26
Compare
pjbgf
approved these changes
May 20, 2026
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.
Replace the per-branch memory.NewStorage() planning fetch with a streaming extractor that pulls only (commit -> parent hashes) tuples from the tree:0-filtered pack.
Previously, bootstrap planning materialized the entire commit set (~1.4M decoded commits for linux, ~5 GiB) just to read each commit's ParentHashes. The new path reads the pack incrementally, extracting parents from each commit as it arrives and discarding the bytes; a bounded LRU keeps recent objects in memory only long enough to resolve deltas. Planning then walks the resulting parents map directly.
Measured against
replicate --all-refs https://github.com/torvalds/linux.gitinto a local git-http-backend target:Note
Medium Risk
Moderate risk: introduces new low-memory pack parsing logic (including temp-file spill and delta-base caching) and refactors v2 fetch envelope handling, which could affect correctness/performance on unusual pack/delta layouts or constrained disks.
Overview
Adds a streaming
ExtractCommitParentspath that parses atree:0packfile and returns only(commit -> parent hashes), using a bounded LRU cache for delta resolution and spilling non-seekable inputs to a temp pack file to keep go-git in low-memory mode.Introduces
RefService.FetchCommitParentsand refactors v2 fetch parsing intoconsumeV2FetchPack, allowing callers to either store the pack (UpdateObjectStorage) or consume the demuxed pack stream.Updates batched bootstrap planning to fetch only commit-parent metadata (instead of materializing a full in-memory object store) and adds new planner walkers
FirstParentChainFromParents/TopoChainFromParentsplus tests to validate they match the storer-based traversal.Reviewed by Cursor Bugbot for commit ede27fd. Configure here.