perf(statusline): build ctx once per run instead of once per script #15

Merged
guochao merged 1 commit from guochao/agent-run:perf-statusline-hoist-context into master 2026-06-13 00:22:08 +00:00
Owner

build_context_table runs git rev-parse + git status --porcelain,
which was called on every iteration of the parts loop. In huge repos
like Chromium each call costs ~3s, so the 8-script loop took ~24s when
cwd was heavy. The static fields (stdin, env, cwd, git) don't vary
across scripts, so hoist the call to before the loop. Cuts git
subprocess invocations from 2*N to 2, total wall time from ~86ms to
~20ms in this repo, and from ~24s to ~3s in Chromium.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

build_context_table runs `git rev-parse` + `git status --porcelain`, which was called on every iteration of the parts loop. In huge repos like Chromium each call costs ~3s, so the 8-script loop took ~24s when cwd was heavy. The static fields (stdin, env, cwd, git) don't vary across scripts, so hoist the call to before the loop. Cuts git subprocess invocations from 2*N to 2, total wall time from ~86ms to ~20ms in this repo, and from ~24s to ~3s in Chromium. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
build_context_table runs `git rev-parse` + `git status --porcelain`,
which was called on every iteration of the parts loop. In huge repos
like Chromium each call costs ~3s, so the 8-script loop took ~24s when
cwd was heavy. The static fields (stdin, env, cwd, git) don't vary
across scripts, so hoist the call to before the loop. Cuts git
subprocess invocations from 2*N to 2, total wall time from ~86ms to
~20ms in this repo, and from ~24s to ~3s in Chromium.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
guochao merged commit e21c767f18 into master 2026-06-13 00:22:08 +00:00
guochao deleted branch perf-statusline-hoist-context 2026-06-13 00:22:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: public/agent-run#15
No description provided.