Checking agent memory against 100,000 files, faster than git
Every time a coding agent starts a session, Sage checks whether the files behind each remembered belief have changed. The build plan's budget was 300 ms on a 100k-file repo with a warm cache. Timed from outside, with process start-up included, the check now beats git status.
hyperfine -N, as an outside process.
git status
47.0 ms vs 80.8 ms, both timed from outside.
git diff t0
The question Sage's check actually answers: 123.6 ms in git.
git status, and with the cache off.
Timed the same way as git, Sage is the fastest line
Each command is started directly by hyperfine (-N, no shell), 5 warm-up runs and 50 timed runs. Plain git diff does strictly less work than Sage: it never looks for untracked files or compares against an older commit.
The native status path is more than twice as fast as asking git
warm example, back to back. SAGE_GIT_STATUS=1 forces the git status path.
Seven costs, seven fixes
.git/index directly and scan the disk in parallel. Each directory's tracked files are one sorted run of the index, and ignore rules only run for untracked paths. Anything unusual falls back to git.
Same answers, whichever path computes them
Every file at t0 is an anchor, checked against the working tree three ways. All three agree on every per-file result. Differential tests also hold the native snapshot equal to git status on edits, deletions, untracked files, nested ignore rules, force-added files and case-only renames.
| Anchor status | Native | Via git status | Cache off | |
|---|---|---|---|---|
| Same | 99,799 | 99,799 | 99,799 | match |
| Relocated (moved) | 100 | 100 | 100 | match |
| Gone (deleted) | 100 | 100 | 100 | match |
| Modified | 1 | 1 | 1 | match |
Re-checking a search on ky
A search behind a belief is re-run only over files that changed. Across 40 commits of sindresorhus/ky, Sage re-searched 20 changed files in about 50 ms, and the result matched git grep at both commits (the same 14 files).
> hyperfine -N --warmup 5 --runs 50 --export-markdown race.md ... | Command | Mean [ms] | Change | Factor | |:----------------------------------|-------------:|-------:|:--------------| | git status | 80.8 ± 2.2 | | | | git diff | 52.7 ± 3.9 | -34.8% | (1.5x faster) | | git diff t0 | 123.6 ± 11.9 | +52.9% | (1.5x slower) | | sage check (t0 -> working tree) | 47.0 ± 3.6 | -41.9% | (1.7x faster) |
git status.Windows laptop, synthetic 100k-file repo
Measured 13 Oct 2026 on a Ryzen 5 5600H (12 threads), Windows 11, git 2.46.0, hyperfine 2.0.0. The test repo is built by bench/make_repo.py: 1,000 folders of 100 one-line TypeScript files, then a commit that moves 100 files, deletes 100 and edits 1. Tree ids depend only on content, and a rebuild from the script matched the measured repo exactly (t0^{tree} 1965611…, HEAD^{tree} f117aec…).
Every timing in the race comes from hyperfine -N, so git and Sage pay the same process start-up (an empty process takes about 6 ms here). Sage is given t0's commit id, as its ledger stores ids; resolving a tag would start git first. Screenshots were taken of a real Windows Terminal window by bench/capture.ps1, running bench/run.sh. Real repos have larger files and messier histories, and git is faster on Linux and macOS, so expect different ratios there.