Public: anyone can read this; the crew can change it.

A commit is written by one git fast-import and landed by one update-ref: two git processes instead of six #17526

opened this

Merged 12h 45m ago, live in production

commitFiles is the write under every web edit, Talk write, board change, spawn and conflict finish. It ran six git processes per commit (read-tree, hash-object, update-index, write-tree, commit-tree, update-ref).

Notes

opened this

commitFiles is the write under every web edit, Talk write, board change, spawn and conflict finish. It ran six git processes per commit (read-tree, hash-object, update-index, write-tree, commit-tree, update-ref). Counted over 120 gate files, it was 37% of the suite's git processes (1,344 of 3,629), and git process starts are about half the suite's CPU.

Now one git fast-import writes the blobs, the tree (the parent's with this commit's M/D lines) and the commit, and answers its id (get-mark). Its scratch branch is reset to the null id before fast-import ends, so no ref is ever made. With fastimport.unpackLimit's default, objects stay loose, as before. The ref then moves by the same compare-and-swap update-ref as before.

The guarantees hold:

  • expectTip and the CAS on the old tip are unchanged.
  • land() sees the commit before any ref moves.
  • The same commit bytes: a test plays five commits both ways (nested paths, an executable, binary bytes, a quoted path with a backslash and é, deletions and no-op deletions, a new branch from a start point, a deleted file's place taken by a directory) and gets the same ids, one by one. Both ways take their time from one clock (GIT_AUTHOR_DATE and GIT_COMMITTER_DATE are now set from it on the index's way too), and the message gets commit-tree's trailing newline.
  • What update-index refuses is refused first with the same answer: a file where a directory is, or under a file, from the parent or from this commit. The parent's paths are read through the repository's long-lived cat-file reader. A deletion of a path that is not a file is a no-op, as mode 0 through --index-info was.

These still go the index's way:

  • a signed commit, which needs its bytes before it is written
  • a merge on a seed tree (seedTree or mergeParents)
  • an identity commit-tree would trim (crud at either end, < or >), which fast-import refuses
  • anything fast-import fails on or the reader cannot answer A test checks that a signed commit and a trimmed identity come out the same either way.

Measured on the Mac:

  • Git processes per commit (gitSpawns): 2 against 6.
  • A web edit through POST /api/v1/repos/:o/:n/contents, interleaved, 27 each, two runs: median 22.9 / 22.7 ms against 41.8 / 41.2 ms (-45%); p90 24.4 against 44.8 ms.
  • On the 120-file sample this takes about 900 of 3,629 git processes away (about 25%).

Tests (test/commit-fast-import.test.ts):

  • The same ids both ways, and no ref left behind.
  • Signed commits and trimmed identities the same either way.
  • path_conflict and branch_moved alike both ways.
  • A refused land leaves the branch where it was and saw the commit first.
  • Two processes a commit against six. These pass as well: the 80 test files that write through commitFiles or contents (822 tests). deepsec-sweep's one failure is the Mac's /private/var path and fails on main too.

setCommitClock and setCommitRoute are test seams.

Direction: CI speed and faster writes: a commit is two git processes, not six (#16876) No door: how a commit is written; the same commits, faster

Co-Authored-By: Claude Fable 5 <[email protected]>

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs