Improve Git monorepo performance with a file system monitor
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`.
Related posts
- Measuring Git performance with OpenTelemetry
GitHub Engineering mediumAdepttrace2receiver is an open source OpenTelemetry collector component that converts Git's built-in Trace2 performance events into OpenTelemetry spans and metrics. It supports both per-command distributed traces, mapping nested child processes and regions into parent-child spans, and fleet-wide aggregation for analyzing monorepo performance across users and machines. A git status trace on the Linux repo shows command time dropping from 970 ms to 204 ms with FSMonitor and to 40 ms with FSMonitor plus Untracked Cache, with the regions responsible for each saving identified. Kusto queries in Azure Data Explorer then compute command frequency and P80 durations grouped by repository, OS and processor.
- Optimizing Git’s Merge Machinery, #3
Palantir hardMasterGit's merge machinery can skip rename detection for source files whose renames cannot change the merge result: files unmodified on the unrenamed side of history, and files not needed for directory rename detection's majority rule. Exploiting this meant pushing three-commit merge context across the old diff/rename-detection abstraction boundary, which only knew about two trees. For a typical cherry-pick touching ~10 files against 5K upstream renames, the comparison matrix shrinks from 5K×5K to ~10×5K. The mega-renames testcase drops from 130s to 11.4s on top of basename-guided detection, or from 1800s to 16s alone. The change ships in git 2.32.
- Scaling merge-ort across GitHub
GitHub Engineering mediumAdeptGitHub replaced its libgit2-based server-side merge and rebase implementation with Git's merge-ort strategy, which needs no working directory and matches what the Git command line does. Both changes were validated with Scientist experiments that ran old and new code paths side by side in production. For merges, P50 dropped from about 71 ms to under 8 ms and P99 from 1.63 s to about 330 ms, a 10x speedup on the github/github monolith. Rebases moved to the new git-replay subcommand, and in testing they took under 10 minutes of compute versus 2.56 hours with libgit2.
- Improving Git push times through faster server side hooks
GitHub Engineering mediumAdeptGitHub cut pre-receive hook execution time on every Git push from about 880ms median to 10ms, dropping P99 by 95%, by rewriting the hooks from Ruby into its Go Git service. The Ruby hooks ran as subprocesses under Git and loaded the Rails monolith's 450+ gems on every push, twice per push (quarantine and post-receive), so an empty push could take over two seconds. Pruning outlier dependencies found with a debugger and strace saved 350-400ms, but load time would creep back as the monolith grew. The rewrite instead passes the needed configuration through an existing per-push data mechanism and rolled out behind a feature flag.
- Tame Dependabot: Group your updates, slow the cadence, keep security fast
GitHub Engineering mediumAdeptGrouping Dependabot updates, moving the schedule from daily to monthly and covering every ecosystem actually used turns a steady stream of single-dependency pull requests into one batched PR per ecosystem per month. Microsoft's GCToolkit, where 92 of 578 commits were Dependabot bumps, made this change with about a dozen lines of `dependabot.yml`, including a wildcard `groups` pattern and a newly added `maven` entry. Security updates still open immediately, independent of the schedule, as long as security updates, alerts and the dependency graph are enabled. A new default three-day cooldown also holds back version updates for freshly published releases to reduce supply-chain risk, and is tunable via `cooldown`. Monorepos can collapse per-directory bumps using `directories` globs with `group-by: dependency-name`.