Repository navigation
perf: stop the code tab forking git per tree entry - #421
Merged
Merged
Conversation
mfwolffe
force-pushed
the
perf/code-tab-git-forks
branch
from
September 2, 2026 07:02
728afef to
a6eb19f
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3 (CPU) of the availability campaign: the repo home / code tab is
the most-crawled page on the site and forked git O(entries) per
anonymous request.
de3ab45a— every git subprocess ininternal/repos/gitnow goesthrough one helper that counts forks (
repogit.ForkCount()) and cancarry process-wide policy. Read-only calls on the code-tab paths get
a 30 s deadline (
repogit.ReadTimeout); blob streaming andpack/transport are excluded.
909ba217—repogit.EntryLastCommits: one streamedgit log --name-onlywalk per directory, killed mid-stream onceevery entry resolves, bounded at 2,000 commits. Entries the walk
can't resolve fall back to the old per-path
git log -1, sorendered output is unchanged.
6c0a803b—internal/web/handlers/repo/treecache: OID-keyed LRU +singleflight over the last-commit map,
rev-list --count, thels-tree -rlanguage aggregate and thelog -n 500contributortally. 2,048 / 512 entries, 10 min TTL. Invalidation is structural —
a push changes the commit OID, so it changes the key; no hook to
forget.
eeba23c1— wires it throughrepo.Deps.TreeCache, built once ininternal/web/repo_wiring.go(same shape ashttpcache.PageCache).98219e85— handler-level fork-count regression test.a6eb19f8—docs/internal/caching.md,docs/internal/code-tab.md,sitrep item ticked.
Fork counts (measured, cold anonymous root-tree render)
O(N) → O(1) in entry count. "Before" measured on this branch with the
walk disabled, so it is the same fixture and the same counter.
Tests
internal/repos/git— single-walk resolver: root + nested dirs,renames, never-touched entries, walk-bound stragglers, parity
against per-path
git log -1, fork count constant at 5 and 60entries, bad ref
internal/web/handlers/repo/treecache— hit/miss, OID-changeinvalidation, key independence, TTL, LRU eviction, errors not
cached, singleflight collapse, nil receiver
internal/web/handlers/repo—TestCodeTree_*: forks constantin entry count + ceiling, warm cache drops forks with identical
body, post-push render is not stale
make cigreen end to end against Postgres 16 (golangci-lint2.13 + gofumpt, all boundary/spdx/unused/migration/systemd lints,
verify-api-docs, full
go test ./..., build), rebased ontocurrent trunk