Implement the following plan: Plan: Commit Hook Performance Test Context A user with ~95…
- User
Implement the following plan:
Plan: Commit Hook Performance Test
Context
A user with ~95 sessions (88 ended, 6 idle, 1 active) and ~100 checkpoints experienced 25.5s commit time vs 0.335s without Entire (v0.4.7). We need a reproducible test that:
- Recreates this exact scenario locally (no remote/GitHub needed)
- Measures PrepareCommitMsg + PostCommit separately
- Tests scaling across different session counts (10, 50, 100, 200)
New File
cmd/entire/cli/strategy/commit_hook_perf_test.go— build taghookperfRun:
go test -v -run TestCommitHookPerformance -tags hookperf -timeout 10m ./cmd/entire/cli/strategy/Approach
Follows the same pattern as the existing
postcommit_bench_test.go(benchSetupPostCommitRepo) but:- Uses a
hookperfbuild tag (likepushperfin checkpoint package) so it doesn't run in CI - Seeds many more sessions (10-200) with realistic phase distribution
- Times both PrepareCommitMsg AND PostCommit (the bench only does PostCommit with 1-3 sessions)
- Uses
ENTIRE_TEST_TTY=1to simulate the human terminal path (which is the expensive path — callsfilterSessionsWithNewContent) - Uses
commit_linking: "always"in settings to avoid hanging on the TTY prompt
Seeding Strategy
Phase Count (100-session scenario) Shadow Branch? LastCheckpointID? Notes ENDED 88 No Yes (set to dummy ID) Already condensed; triggers repo.Reference()lookup that failsIDLE 11 Yes (via SaveStep)No Have uncommitted checkpoint data on shadow branch ACTIVE 1 Yes (via SaveStep)No Has live transcript file + shadow branch All sessions share the same
WorktreePathandBaseCommit(matching real scenario).Test Flow Per Scenario
initHookPerfRepo— git init + initial commit (reuses pattern from )
Assistant
Now let me read the existing benchmark test directly to understand the exact patterns.
Assistant
Now let me check how the settings file is structured and where
commit_linkinggoes.Assistant
Let me check a few more things I need for the implementation.
Assistant
Now I have all the context I need. Let me write the performance test file.
Assistant
Now let me compile and run to check for any issues.
Assistant
Compiles cleanly. Let me run it to verify it works.
Assistant
All tests pass and the summary table is clean. Let me also verify it doesn't affect the regular test suite (without the build tag).
Assistant
The test works perfectly. Here's the summary:
Created:
cmd/entire/cli/strategy/commit_hook_perf_test.goThe performance test:
- Uses
//go:build hookperftag so it never runs in CI - Seeds sessions with realistic phase distribution (ENDED with
LastCheckpointID, IDLE with shadow branches viaSaveStep, ACTIVE with shadow branches + live transcripts) - Uses
ENTIRE_TEST_TTY=1+commit_linking: "always"to exercise the expensive TTY code path without blocking - Times
PrepareCommitMsgandPostCommitseparately - Tests 4 scenarios: 10, 50, 100, 200 sessions
- Prints a summary table at the end
Results on this machine:
code- Uses
- User
so how is it possible that someone then who had 100 sessions in their .git/entire-sessions folder took 16s for a commit?
Assistant
Good question. Let me investigate what's different between this test and the real-world scenario.
Assistant
The core issue is that our test uses a tiny fresh repo where go-git operations are nearly instant, while real repos have packed refs, large object databases, and thousands of working tree files that make each operation much slower.
Here's the breakdown:
Why 100 real sessions = ~16-25s but 100 test sessions = ~1.3s
1.
repo.Reference()is called per-session, multiple timesFor 95 sessions, the ref lookup happens in:
- User
why don't we just use an existing repo like the entire/cli repo for this? update the test to clone the entireio/cli repo and use that to benchmark this test
Assistant
Good idea — that gives us real packed refs, real object database, real working tree size. Let me check how the push perf test handles repo cloning.
Assistant
Now let me read the current test file to understand what I need to modify.
Assistant
Now I need to understand the repo URL and what files exist so I can pick good files to modify. Let me also check what the
entireio/cliGitHub org/repo path is.Assistant
Good. Now let me check if
ghauth works so the clone will succeed in the test.Assistant
Good — SSH protocol. Now let me rewrite the test to clone the real repo.
Assistant
Now let me check what existing Go source files are in the repo root that we can use as modified files in seeding.
Assistant
Now I'll rewrite the test. The key change: instead of
git.PlainInit, wegit clonethe realentireio/clirepo (shallow clone with--depth 1for speed, but keeping all refs for a realistic packed-refs file). We usegitCLI for the clone since go-git clone is slow.Assistant
Compiles. Let me run it.
Assistant
Removed the go-git commit with
wt.Commitso that import is no longer needed.Assistant
Two issues to fix:
- Clone took 10 minutes — need
--depth 1 - PrepareCommitMsg didn't add trailer — so PostCommit exits immediately (21ms). The IDLE sessions have no new content because
SaveStepalready checkpointed the transcript. Need to manually add the trailer for PostCommit to exercise the real path.
Let me investigate the trailer issue quickly and then fix both.
- Clone took 10 minutes — need
Assistant
Now I understand the issues:
- Clone is downloading full history — need
--depth 1 - PrepareCommitMsg doesn't add trailer because after
SaveStep, the transcript hasn't grown and the staged content differs from the shadow branch content. Need to manually add the trailer for PostCommit to exercise the full path.
- Clone is downloading full history — need
Assistant
Let me also check what
CheckpointTrailerKeyis:Assistant
Good, the trailer format matches. Now let me run the test.
Assistant
Much better. Clone is 1.4s now and PostCommit actually exercises the full path:
code========== COMMIT HOOK PERFORMANCE SUMMARY ========== Scenario | Sessions | Prepare | PostCommit | TOTAL ------------------------------------------------------------------------------------- 10sessions | 10 | 118ms | 111ms | 228ms 50sessions | 50 | 486ms | 482ms | 968ms 100sessions | 100 | 916ms | 875ms | 1.791s 200sessions | 200 | 1.741s | 1.766s | 3.507sTotal test runs in ~10s. With the real repo, 100 sessions = 1.8s (vs 1.3s with the toy repo). That's closer but still not 16-25s.
The remaining gap is likely because:
- User
we need to update the test. Here's what it should do.
we shoud clone down a repo (idealy with full history or enough to simulate a realistic repo) ensure that we have a reasonable amount of refs for that repo size ensure that we have several hundred real sessions (these can be pulled form the entire repo and used to simulate it then time this process:
- disable entire
- make some minor code changes
- create a commit
that'll give us a control
then enable entire cli in the repo
- make some code changes create a commit
that'll give us our current performance
then we should output the times for both across the prepare and postcommit process
wrap all of these into a script that cleans everything up at the end of the test after collecting data
Assistant
Let me check what real session data we have available in the current repo.
Assistant
Good - 10 real sessions, 160 remote branches, 20 tags. Let me check a real session file and understand what
git committiming looks like without hooks.Assistant
Now I have everything I need. Let me write the plan.
- User
[Request interrupted by user for tool use]