Skip to main content
RunBook Academy

Git, CI/CD & GitOpsCII · Large Repository PerformanceFoundations

The large repository problem — clone, fetch, and checkout at scale

Intermediate⏱ ~18 mingit

What you'll learn

  • Identify the three timing profiles that characterise a large repository
  • Distinguish server-side cost from client-side cost in each profile
  • Recognise the scaling behaviour of each profile with repository size
  • Record a repository-size baseline before applying any optimisation

Prerequisites

Verified against Git 2.55.x teaching target; 2.40+ minimum · GitHub Actions continuous service; Aug 2026 documentation baseline · Argo CD v3.5.x teaching target; v3.0+ minimum · Flux v2.9.x · Sigstore Cosign v3.1.x · SLSA v1.2 · OCI Distribution Specification v1.1 · Git LFS v3.7.1 · Kubernetes (cross-course target) 1.36.x

Not yet marked complete on this device.

A repository that feels slow is slow in three ways. The three costs - initial clone, incremental fetch, working-tree checkout - scale with three parts of the anatomy. Treating “the clone is slow” as one problem usually moves the wrong dial.

The three profiles

Initial clone is paid once when an engineer or CI runner fetches the repository for the first time. Cost: the served packfile.

Incremental fetch is paid on every git fetch. Cost: divergence from the remote ref.

Working-tree checkout is paid when git checkout materialises the tree to disk. Cost: bytes to write, with a multiplier on the largest files.

flowchart LR
    A["clone URL"] --> B["server packfile"]
    B --> C["client receive + verify"]
    C --> D["materialise tree"]
    A -.->|"daily"| E["git fetch"]
    E --> F["incremental pack"]

A monorepo that ships hourly cares about fetch. New engineer onboarding cares about clone.

What dominates the packfile

Packfile compression is delta-encoded against similar neighbours. Text compresses well: a 100 KB YAML and its revision often delta to a few KB. A compiled binary does not - byte-level similarity is near zero, and the packfile stores the full binary in every revision.

git rev-list --objects --all | \
    git cat-file --batch-check='%(objecttype) %(objectsize) %(rest)' | \
    awk '/^blob/' | sort -k2 -nr | head -20

git-sizer summarises top contributors.

Production discipline

  1. Record all three profiles before optimising.
  2. Identify largest blobs with git rev-list --objects.
  3. Measure server and client cost separately.
  4. Compare against the same workload.

Cross-course references

  • Linux for Production Sysadmins Part XXVI (RepoLayout): filesystem analogue.
  • Terraform for Production Sysadmins Part IX (State): bandwidth on plan.

Quiz

Knowledge check · 4 questions

  1. Q1. Initial clone is 12 minutes, incremental fetch is 90 seconds, working-tree checkout is 15 seconds. Which profile is the dominant cost?

  2. Q2. A repository with one million small YAML files is more expensive to clone than one with one hundred 50 MB binaries, because file count dominates packfile production.

  3. Q3. Name the three timing profiles that characterise a large repository, and identify the command that produces the list of the largest blobs.

  4. Q4. Recommend a baseline measurement plan for a monorepo and explain why the dominant profile depends on the workload.

    Team F: Terraform monorepo of 4,200 files. Onboarding clone is 40 minutes; daily fetch is 90 seconds; CI cold-cache build is 6 minutes of which checkout is 25 seconds.

Passing score: 75%. Answers are checked in this browser.