Add entire perf command to find slow performance hooks etc.#652
Add entire perf command to find slow performance hooks etc.#652
entire perf command to find slow performance hooks etc.#652Conversation
Entire-Checkpoint: 22415ab59f02
Add collectPerfEntries() to read JSONL log files and return the last N perf entries in newest-first order, with optional hook type filtering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: eaf01bcc91eb
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: c3b7ec761aa8
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: e5bf775d5e75
Entire-Checkpoint: c75be2c5408c
Entire-Checkpoint: 3506e3209cd5
Entire-Checkpoint: 2bc23d89214f
Entire-Checkpoint: 7d7c4e94c454
PR SummaryMedium Risk Overview Extends Written by Cursor Bugbot for commit c1c901d. Configure here. |
| tree := buildCommittedTree(t, map[string]string{ | ||
| "a3/b2c4d5e6f7/0/prompt.txt": "Real session prompt", | ||
| "a3/b2c4d5e6f7/1/metadata.json": `{"session_id":"test"}`, | ||
| "a3/b2c4d5e6f7/0/prompt.txt": "Real session prompt", |
There was a problem hiding this comment.
These kept coming up for some reason. 🤷
There was a problem hiding this comment.
We could add golangci-lint fmt in mise to ensure we keep it to a specific format.
| continue | ||
| } | ||
| s.postCommitProcessSession(ctx, repo, state, &transitionCtx, checkpointID, | ||
| iterCtx, iterSpan := processSessionsLoop.Iteration(loopCtx) |
There was a problem hiding this comment.
Tracking cumulative timings for looped steps didn't really work with the existing package. This adds a new abstraction for loops and other code that calls the the same operation multiple times. It will group it hierarchically under the processSessionsLoop span and render it as a tree in the entire perf command.
There was a problem hiding this comment.
Pull request overview
This PR adds a new entire perf CLI command for viewing hook performance traces, extends the perf/span package with loop iteration tracking (LoopSpan), and integrates the new loop span into the PostCommit hook to emit per-session timing data.
Changes:
- New
entire perfcommand (perf.go,perf_cmd.go) that parses JSONL log entries and renders hierarchical timing tables with sub-step breakdowns - New
LoopSpantype inperf/span.gowithStartLoop/Iteration/Endpattern, pluschildStepKeydeduplication for repeated child span names - Integration of
LoopSpaninPostCommithook to track per-session processing times
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/entire/cli/perf.go |
New file: JSONL log parser, sub-step detection, and ASCII table renderer |
cmd/entire/cli/perf_cmd.go |
New file: Cobra command definition for entire perf |
cmd/entire/cli/perf_test.go |
New file: Tests for parsing, collecting, rendering, and flag validation |
perf/span.go |
Adds childStepKey dedup, grandchild emission, LoopSpan type |
perf/span_test.go |
Tests for deduplication, loop span creation, auto-end, and errors |
cmd/entire/cli/strategy/manual_commit_hooks.go |
Wraps session loop with StartLoop/Iteration/End |
cmd/entire/cli/root.go |
Registers newPerfCmd() |
cmd/entire/cli/strategy/common_test.go |
Whitespace formatting cleanup |
Entire-Checkpoint: e6ea5a3d3580
Entire-Checkpoint: afa161063fc3
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…to feat/entire-perf-command
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…to feat/entire-perf-command
|
Bugbot run |
entire perfsubcommandAdds a new
entire perfCLI command that displays hook performance traces, and extends theperf/spanpackage with loop iteration tracking.New command:
entire perfParses structured perf log entries from
.entire/logs/entire.logand renders them as formatted timing tables with hierarchical sub-step breakdowns.entire perf— show the most recent hook traceentire perf --last 5— show the last 5 tracesentire perf --hook post-commit— filter by hook typePerf traces require
ENTIRE_LOG_LEVEL=DEBUGto be enabled.Implementation (
cmd/entire/cli/perf.go,perf_cmd.go):steps.*_msandsteps.*_errkeys into a hierarchical step treefoo.0,foo.1are nested under their parentfoowhen the parent exists├─/└─) with manual padding to avoid UTF-8 multi-byte alignment issues--lastflag (must be >= 1)The result will look something like this:
❯ go run ./cmd/entire perf --hook post-commit --last 2 post-commit 123ms 2026-03-06T16:35:48-08:00 STEP DURATION cleanup_shadow_branches 12ms find_sessions_for_worktree 0ms open_repository_and_head 0ms process_sessions 100ms ├─ process_sessions.0 3ms ├─ process_sessions.1 0ms ├─ process_sessions.2 95ms ├─ process_sessions.3 0ms ├─ process_sessions.4 0ms └─ process_sessions.5 0ms resolve_commit_trees 5ms post-commit 595ms 2026-03-06T15:54:13-08:00 STEP DURATION cleanup_shadow_branches 13ms find_sessions_for_worktree 0ms open_repository_and_head 0ms process_sessions 570ms ├─ process_sessions.0 3ms ├─ process_sessions.1 566ms ├─ process_sessions.2 0ms ├─ process_sessions.3 0ms └─ process_sessions.4 0ms resolve_commit_trees 6msperf/span: LoopSpan and child deduplicationExtends the span package to support tracking loop iterations as grouped sub-spans.
LoopSpan— new type that wraps a grouping span;Iteration()creates child spans,End()auto-ends unfinished iterationschildStepKey()— deduplicates child span names (.1,.2suffixes) so repeated loop iterations don't overwrite each other in log outputsteps.<name>.<index>_msentries with 0-based indexingHook integration
PostCommitinmanual_commit_hooks.gonow wraps the session processing loop withStartLoop/Iteration/Endto emit per-session timing in perf traces.Other
.goreleaser.yaml: Removed installation link from Discord release announcement templatestrategy/common_test.go: Whitespace formatting cleanup