fix: optimize prepare-commit-msg hook performance for large repos#553
fix: optimize prepare-commit-msg hook performance for large repos#553gtrrz-victor merged 2 commits intomainfrom
Conversation
PR SummaryMedium Risk Overview Avoids heavy transcript parsing in hot paths. Reduces expensive go-git diffs in list views. Temporary checkpoint filtering switches from a full diff ( Written by Cursor Bugbot for commit ea28a47. Configure here. |
There was a problem hiding this comment.
Pull request overview
Improves performance of Entire’s git hook and checkpoint listing paths in large repositories by avoiding expensive go-git operations and repeated work, while adding benchmarks to measure improvements.
Changes:
- Replaces staged-file detection with
git diff --cached --name-onlyand caches staged files across session checks. - Optimizes last-prompt retrieval by reading
prompt.txtdirectly from git trees instead of parsing full transcripts. - Reduces
entire explaincheckpoint-list overhead by reading prompts from the metadata tree and using a cheap “any changes” check.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cmd/entire/cli/strategy/manual_commit_hooks.go | Caches staged files, switches staged-file detection to git CLI, and optimizes last-prompt lookup via prompt.txt in trees. |
| cmd/entire/cli/strategy/mid_turn_commit_test.go | Updates tests to pass staged files via the new contentCheckOpts path. |
| cmd/entire/cli/explain.go | Avoids slow transcript reads in list views by reading prompts from the metadata tree and using a lightweight tree-hash change check. |
| cmd/entire/cli/strategy/preparecommitmsg_bench_test.go | Adds benchmark harnesses for PrepareCommitMsg and staged-file detection across repo sizes/session counts. |
Replace go-git's worktree.Status() with native `git diff --cached` in getStagedFiles (constant time vs O(all files)), cache the staged files list across sessions to eliminate redundant calls, and read prompt.txt directly from the shadow branch tree instead of parsing the full transcript in getLastPrompt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: b4ec64cad4b6
Entire-Checkpoint: 1e3fe3c13bbf
26377af to
35dec30
Compare
Summary
getStagedFileswith native git CLI: Swap go-git'sworktree.Status()(O(all files), scans entire working tree) withgit diff --cached --name-only(constant time, uses git's optimized index and fsmonitor)filterSessionsWithNewContentand pass viacontentCheckOptsstruct, eliminating up to 3×N redundant calls for N sessionsgetLastPrompt: Readprompt.txtdirectly from the shadow branch tree instead of callingextractSessionData()which parses the full transcript (token counting, context generation, prompt extraction)BenchmarkPrepareCommitMsgwith 6 sub-benchmarks (Small/Medium/Large repo × 1/3 sessions) andBenchmarkGetStagedFilesfor isolated measurementAlso includes the prior fix for
entire explainhanging on repos with many checkpoints (commiteff1e18d).Test plan
mise run fmt— cleanmise run lint— 0 issuesmise run test:ci— all tests pass (unit + integration)git commitwith Entire enabled on a large repo no longer hangs🤖 Generated with Claude Code