Add entire trace command to find slow performance hooks etc.#652
Conversation
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. |
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 |
There was a problem hiding this comment.
From Claude:
Review
Consolidated review covering 1 must-fix and 3 should-fix items. See inline comments.
Overall the PR is clean — follows project conventions, good test coverage, nice separation of concerns. These are the items worth addressing before merge.
entire perf command to find slow performance hooks etc.entire trace command to find slow performance hooks etc.
Entire-Checkpoint: 667a3f4cd3a2
Increase bufio.Scanner max line size to 1MB in collectTraceEntries since the shared log file may contain large entries from other components. Also fix the attrs slice capacity in Span.End() to account for grandchild attributes, avoiding unnecessary reallocation. Entire-Checkpoint: e39fa6f2bd3e
Entire-Checkpoint: 7b6d33cfcdb8
- Use ~ separator in childStepKey dedup to avoid collision with grandchild . indexing (e.g. steps.foo~1_ms vs steps.foo.1_ms) - Auto-end iteration children in LoopSpan.End() so durations are captured at loop-end time, not deferred to root span - Use best-effort field extraction in parseTraceEntry: mistyped op, duration_ms, or error fields keep zero values instead of discarding the entire entry - Fix test comment: iterations are auto-ended by loop.End(), not root.End() Entire-Checkpoint: 405fd6ef50b1
- Use slices.Sort/SortFunc/Reverse instead of sort package (matches codebase conventions) - Add cheap string pre-filter before full JSON parse to skip non-perf log lines without marshalling cost - Add nolint:errcheck directives for intentional best-effort json.Unmarshal calls - Fix stale comment in span.go (says .1 but code uses ~1) Entire-Checkpoint: 8efdc71f54f1
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
entire tracecommandAdds a new
entire traceCLI command that displays hook performance traces, and extends theperf/spanpackage with loop iteration tracking.New command:
entire traceParses structured perf log entries from
.entire/logs/entire.logand renders them as formatted timing tables with hierarchical sub-step breakdowns.entire trace— show the most recent hook traceentire trace --last 5— show the last 5 tracesentire trace --hook post-commit— filter by hook typeTraces require
ENTIRE_LOG_LEVEL=DEBUGto be enabled.Implementation (
cmd/entire/cli/trace.go,trace_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)Example output:
perf/span: LoopSpan and child deduplicationExtends the span package to support tracking loop iterations as grouped sub-spans.
LoopSpan— 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 traces.