fix/streaming-bundles #1

Merged
kreato merged 2 commits from fix/streaming-bundles into main 2026-11-06 21:26:29 +00:00
Owner
No description provided.
The sidecar (256Mi) was OOM-killed whenever it built a bundle of a ~150 MiB
repository: serving FetchRepo, and replicating a large initial push.
go-git's packfile.Encoder materialises every object before writing (78-107
MiB heap for a 64 MiB test repo), and the bundle repo used a 96 MiB object
cache. Peers retried the pull every pass, each killed attempt leaking a
fullbundle-*/bundle-* file next to the owners' repositories (2101 files /
20 GB on one pod).

- internal/git/packwriter.go: our own pack v2 writer. Objects are written
  one at a time as full objects (as packWindow 0 did), content streamed
  through zlib from the object's reader with a size check, trailing SHA-1.
  openBundleRepo uses an 8 MiB object cache and streams objects over 1 MiB
  from disk. Heap growth for the same 64 MiB repos: 1-15 MiB.
- Receive side: go-git's PackWriter/Parser already streams to a seekable
  temp pack (peak ~ one object); storeBundle now uses the same bounded repo
  view. Covered by a memory test on the push-receive path.
- internal/tmpfiles: bundles and spool files go to $GITSYNCD_TMP_DIR or
  $TMPDIR/gitsyncd-bundles (falling back to <repos>/.gitsyncd-tmp when that
  is not writable; the image has no /tmp). S3 WAL checkpoints, the one
  bundle that must survive a restart (why the repos volume was used), go to
  <repos>/.gitsyncd-wal/bundles. Startup sweep removes only regular files
  with gitsyncd's generated names: in the scratch dir, gitsyncd-* in the old
  system temp dir, fullbundle-N/bundle-N/gitsyncd-heal-N at exactly
  <repos>/<owner>/, and unreferenced WAL checkpoints. The uploader rebuilds
  a checkpoint whose file is gone instead of failing forever.
- internal/reconcile: per (peer, repo) exponential backoff for pulls and
  heals, 1x interval doubling to 30m, reset on success; skips are logged at
  debug and counted in gitsyncd_reconcile_backoff_skips_total.
Review found the recursive collectObjects kept one decoded commit per
stack frame alive (+310 MiB heap, +48 MiB stack on a 450k-object repo).
Also sort hashes by bytes instead of hex strings (-99 MiB garbage).
kreato merged commit 2c11556c73 into main 2026-11-06 21:26:29 +00:00
kreato deleted branch fix/streaming-bundles 2026-11-06 21:26:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
infra/gitsyncd!1
No description provided.