Skip to content

perf(git): skip bitmaps for incremental upload-pack and bundle builds - #467

Merged
stuartwdouglas merged 1 commit into
mainfrom
sleeper/upload-pack-no-bitmaps-incremental
Nov 25, 2026
Merged

stuartwdouglas merged 1 commit into
mainfrom
sleeper/upload-pack-no-bitmaps-incremental

Conversation

@stuartwdouglas

Copy link
Copy Markdown
Contributor

Problem

When an upload-pack request's haves aren't covered by a bitmap, git first fills one in by walking the whole tree on the haves side (haves/boundary → boundary-fill-in). On a large monorepo mirror, that costs about the same for a 47-commit gap as for weeks of history. It affects two paths:

  • Incremental fetches served from the mirror. On Roxy workstations, git reads to github.com are redirected to cachew. A clone's catch-up fetch (want new HEAD, have the snapshot commit) lands in serveReadyRepo → git http-backend → upload-pack.
  • Delta bundle builds (git bundle create HEAD ^base), which a clone waits on when the bundle isn't cached yet.

Change

  • serveReadyRepo already buffers the request body for the "not our ref" replay. A /git-upload-pack request whose body has have lines is now marked incremental. Detection uses the same gzip-aware 64 KiB inspect window as clone counting; decodeUploadPackPrefix is factored out of inspectUploadPackBody.
  • Incremental requests run http-backend with GIT_CONFIG_COUNT=1, pack.useBitmaps=false. This is command-scope config, and the mirror's own config is unchanged. The "not our ref" replay gets the same override.
  • Clones (wants only), v2 ls-refs and info/refs keep bitmaps, because a full object walk benefits from them. v0 and v2 requests both take this path.
  • A fetch whose first have falls past the 64 KiB window is treated as a clone and keeps bitmaps. That is today's behaviour.
  • Bundles are built with -c pack.useBitmaps=false.

Measurements

These were taken on the bb-block staging cash-server mirror (git 2.52.1, MIDX bitmap fresh and covering HEAD, boundary traversal on). Each fetch is a protocol v2 fetch through git http-backend with the CGI env cachew uses, two runs each:

have bitmaps on bitmaps off
HEAD~47 13–15s, 4.3 MB <1s, 1.1 MB
HEAD~2000 (~6 days) 24s, 72 MB 8s, 42 MB

pack-objects runs on the same mirror:

  • HEAD~5: 13s on vs <1s off.
  • HEAD~150: 14s vs 1s.
  • ~1 month (10,859 commits): 51s and 316 MB vs 32s and 204 MB.
  • A 47-commit delta bundle build: 14s vs about 1s.

Production baseline for a cold bundle build: snapshot.bundle?base=<main~47> against bb-block prod took 37.2s to first byte (4.49 MB). Part of that may be time spent waiting behind a mirror fetch under WithFetchExclusion.

Not measured: a client advertising many unrelated branch tips as haves. If that proves slow, a cap on have lines is the limit to add.

Testing

  • TestUploadPackSkipsBitmapsOnlyForIncrementalFetches drives the real POST handler and a real git http-backend on the fixture mirror. A PATH wrapper records the pack.usebitmaps value each backend run sees. There are six cases:

    • v2 fetch with haves
    • v0 fetch with haves
    • gzipped v0 fetch with haves
    • fetch replayed after "not our ref" (both runs false)
    • v0 clone
    • v2 ls-refs

    The clone and ls-refs cases expect the value unset. With detection forced off, the three with-haves cases fail.

  • The fake-git bundle test now matches bundle create anywhere in argv, because -c shifts the arguments.

  • go test -race ./internal/strategy/git/ ./internal/gitclone/ passes and tsk is clean.

Follow-up: #466, now a draft, will carry the bundle staleness fix and the tip= hint after this merges.

🤖 Generated with Claude Code

When an upload-pack request's haves aren't covered by a bitmap, git
first fills one in by walking their whole tree. On the cash-server
mirror (bb-block staging, git 2.52.1, MIDX bitmap 9 minutes old,
boundary traversal on), a v2 fetch through http-backend for a 47-commit
gap took 13-15s and sent 4.3 MB with bitmaps, against under 1s and
1.1 MB without. A 2,000-commit gap took 24s and 72 MB against 8s and
42 MB. Delta bundle builds (HEAD ^base) hit the same fill-in: 14s
against about 1s.

serveReadyRepo already buffers the request body. A git-upload-pack
request whose body (gzip-aware, same inspect window as clone counting)
has "have" lines now runs http-backend with pack.useBitmaps=false
through GIT_CONFIG_COUNT. The "not our ref" replay gets the same
override. Clones, ls-refs and info/refs keep bitmaps, which a full
object walk needs. v0 and v2 requests both take this path. Bundles are
built with -c pack.useBitmaps=false. The mirror config is unchanged.

Co-authored-by: Sleeper Service <a6659a6442a259afd31da6e85f71b9e9f3fe127dd3cc88d2ae9fb544922bcb3c>
@stuartwdouglas
stuartwdouglas requested a review from a team as a code owner November 25, 2026 06:35
@stuartwdouglas
stuartwdouglas requested review from inez and removed request for a team November 25, 2026 06:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:36:16.519540Z c01cabc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@stuartwdouglas
stuartwdouglas merged commit 57a2372 into main Nov 25, 2026
7 checks passed
@stuartwdouglas
stuartwdouglas deleted the sleeper/upload-pack-no-bitmaps-incremental branch November 25, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants