fix(beefcake/forgejo): move git subprocess HOME off virtiofs to SSD #756
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "forgejo-git-home"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Every repo-scoped forgejo page has a fixed ~1-2s latency floor independent of how much git work it does: repo home ~2.5s, a raw single-file view ~1-2.7s, commits list 5-7s. Non-repo pages (
/explore, static assets) serve in 2-35ms. Standalone git ops on the repo run in ~5ms, ARC hit 99.8%, last-commit cache warm — so it is not git, disk, or cache.Root cause
forgejo's git
HOMEdefaults toAPP_DATA_PATH/home=/storage/forgejo/data/home, on the/storagevirtiofs (HDD) share. Every git child forgejo spawns opens$HOME/.gitconfigand probes$HOME/.config/git/configat startup, and each such syscall costs 20-100ms over virtiofs vs <1ms on SSD. A single repo page opens the cat-file--batch/--batch-checkreaders (each preceded bygit rev-parseinensureValidGitRepository) plushash-object/rev-list— ~6 git spawns even for a trivial raw-file request — so the per-request cost was ~6x the virtiofs config-read tax: a fixed floor unrelated to actual git work.Diagnosis (live LTS 15.0.3 guest, pprof + execution trace)
os/execon git children;go tool traceattributed the syscall-blocking togit.(*Command).Run, withensureValidGitRepository'srev-parsealone = 2.12s of 2.84s.git rev-parsein the repo: 0.008-0.013s with HOME on tmpfs/SSD vs 0.135-0.835s with HOME on virtiofs; strace showed individual.gitconfigaccess/open/read syscalls at 20-98ms each on virtiofs.Fix
Set
[git] HOME_PATHto/var/lib/forgejo-git-homeon the guest SSD root, mirroringforgejoWorkTmp(tmpfiles-created, forgejo-owned, inReadWritePaths, ephemeral — forgejo rewrites the managed.gitconfigon every start, so no persistence entry needed).Residual / follow-up
After this fix the remaining per-request cost is the raw fork/exec of the many short-lived git subprocesses per repo page. Fully eliminating the floor would require reducing spawn count or faster storage for
stateDir/WORK_DIR— tracked separately.Deploy note
Config-only + a new ephemeral tmpfiles dir; safe as a live switch (no cross-release/systemd change). Not yet deployed.
🤖 Generated with Claude Code
https://claude.ai/code/session_011m7LpmJkaSpr9NiKvaatNv