Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

GitHub Engineering 23 min read Deep dive hardMaster

Scaling Git’s garbage collection

Git's garbage collection historically stored recently-written unreachable objects as individual loose files so their mtimes could govern expiry, which bloated storage, exhausted inodes and slowed repacks in busy repositories at GitHub's 18.6 PB scale. Cruft packs fix this by packing unreachable objects together with a companion .mtimes file holding a 4-byte per-object timestamp, indexed via the pack index, so individual objects can be freshened and expired independently. The --prune=<date> grace period exists to mitigate a race where a concurrent push makes a to-be-deleted object reachable, and cruft pack generation walks reachability to separate reachable from unreachable objects while expiring unreachable clusters all-or-nothing. The work was contributed upstream to Git.

Assumes: Git object modelGit packfiles and pack indexesGit reachability and references

Related posts

  • 20× the CI traffic without getting slower: How we rebuilt Git serving at Datadog

    Datadog Engineering mediumAdept

    Datadog replaced CI fetches from a replicated Gitaly/Praefect cluster with gitretriever, a fleet of independent Git mirrors that poll GitHub per changed ref and fan packfiles out to autoscaled relays over a gRPC signaling stream plus HTTP. Because Git objects are content-addressed, relays install received packfiles without re-indexing. A pack cache serves about half of pack-building fetches without redoing delta compression. Traffic grew 20× in four months while median latency held near 40 ms, and fetch-serving CPU on the old backend fell 3–4×. A read-only HTTP API for ref resolution and file reads also replaced many full clones by internal tools and AI agents.

  • Inside GitHub’s new Git storage architecture

    GitHub Engineering hardMaster

    GitHub's new Git storage architecture, Rubicon, rests on one observation: only reference updates need ordering. Git objects go to Azure Blob Storage, and refs plus the pack manifest go to a small quorum-replicated compare-and-swap log called Ref-CAS. Disposable virtual replicas serve reads and writes from a rebuildable cache, while separate lease-based compaction nodes merge packs in the background, so storage, serving and maintenance scale independently. Ref-CAS replaced blob-based ref logs, which topped out at the mid-hundreds of writes per second or traded away read latency. It reaches tens of thousands of ref operations per second, and internal tests sustained 7,200 pushes per second from 5,000 concurrent agents on one repository.

  • Scaling Git at OpenAI

    OpenAI hardMaster

    Pando is OpenAI's new Git backend for its monorepo, built to handle the concurrent pushes and fetches generated by Codex-driven parallel development while staying fully compatible with the Git protocol and client. Each branch is coordinated independently: incoming packs are stored as immutable blobs and ref versions are recorded in a horizontally scalable metadata store. This gives per-ref serializability but only causal consistency across the repository. Packfiles are reused across fetches rather than generated per client, trading some redundant bytes for far less server CPU and I/O. Compared with three-phase-commit replicas and a shared-manifest WAL in blob storage, Pando avoids a single write ordering point, and in production it cut median push latency nearly 5x while serving close to a petabyte of Git data per day.

  • Automating dead code cleanup

    Meta Engineering mediumAdept

    Meta's SCARF framework finds dead code by building a cross-language, symbol-level dependency graph from Glean and augmenting it with runtime usage data such as API endpoint logs, URI dispatch tables and async job invocations, then garbage-collects unreachable nodes, subgraphs and cycles. Switching from per-symbol classifiers to whole-graph analysis raised dead code removal in one large codebase by nearly 50%, at the cost of a longer indexing and data-pipeline cycle that makes prototyping harder. Over five years SCARF has deleted more than 100 million lines in over 370,000 change requests generated through CodemodService, with some languages auto-merged without review. BigGrep textual-reference checks act as a conservative fallback, accepting false negatives to avoid unsafe deletions.

  • Improve Git monorepo performance with a file system monitor

    GitHub Engineering mediumAdept

    Git 2.37.0 adds a builtin file system monitor daemon (`git fsmonitor--daemon`) for macOS and Windows, enabled by setting `core.fsmonitor` to true. The daemon registers for OS change notifications and keeps an in-memory, time-sorted queue of changed paths. Git commands query it over IPC using tokens that carry the daemon PID and a resync ID, so dropped events trigger a safe full rescan. Combined with `core.untrackedcache`, it cuts `git status` on Chromium and synthetic 1M/2M-file worktrees from 17–85 seconds to under one second by shrinking the refresh_index and untracked-file phases, which also speeds up `git diff`, `git add` and `git checkout`.

The quest for software engineering knowledge.

Look:
Layout: