Problem
Users are reporting heavy system load caused by git processes spawned by the Kilo VS Code extension.
Root Cause Analysis
A comprehensive audit of all git invocation points in the codebase identified the GitStatsPoller (5-second polling interval) as the dominant source of sustained git process load.
Primary Culprit: GitStatsPoller (5s interval)
The GitStatsPoller (instantiated in AgentManagerProvider constructor) runs every 5 seconds when enabled (worktrees.length > 0 || panel !== undefined).
Each poll cycle spawns multiple git processes per worktree:
git worktree list --porcelain — presence probe
git rev-list --left-right --count — ahead/behind per worktree
git rev-parse (multiple calls) — branch resolution, tracking branch, remote
git config, git branch --show-current, git symbolic-ref — fallback chains
git fetch — remote refresh (throttled to 120s, but resolution commands are not)
With 3 worktrees: ~11 git processes every 5 seconds (~132/min)
With 5 worktrees: ~15 git processes every 5 seconds (~180/min)
Plus the CLI backend's own git processes triggered by diffSummary HTTP calls, easily exceeding 200+ git processes/minute.
Secondary: Diff Polling (2.5s interval)
Both DiffViewerProvider and AgentManagerProvider run independent 2.5-second diff polling intervals when their panels are open, triggering additional git commands via the CLI backend.
Key Issues
- No backoff when idle — polls at the same rate whether the user is actively coding or AFK
- No visibility check — polls even when the Agent Manager panel is not visible
- Redundant resolution chains —
resolveTrackingBranch → resolveRemote → resolveDefaultBranch each spawn multiple sub-commands without caching
- Linear scaling — load increases proportionally with worktree count
Load Summary
| Source |
Git processes/min |
When active |
Scales with |
| GitStatsPoller |
~120-240+ |
Always (if worktrees exist or panel open) |
N worktrees |
| AgentManagerProvider diff poll |
~24 (indirect via CLI) |
When diff tab visible |
Constant |
| DiffViewerProvider diff poll |
~24 (indirect via CLI) |
When diff panel open |
Constant |
| Worktree creation |
~15-20 burst |
User action |
One-time |
Recommended Fixes
Priority 1: GitStatsPoller Optimization
- Increase interval when panel is hidden — 30-60s instead of 5s when Agent Manager panel is not visible/active
- Adaptive backoff — if no changes detected across N consecutive polls, progressively increase interval (5s → 10s → 30s → 60s)
- Cache resolution chains —
resolveRemote(), resolveTrackingBranch(), resolveDefaultBranch() results rarely change; cache with 60s TTL
- Batch git operations — use
git for-each-ref or combine multiple rev-parse calls into single process spawns
- Stop polling when unnecessary — don't poll when no worktrees exist AND panel is closed
Priority 2: Diff Polling
- Use filesystem watchers instead of 2.5s
setInterval polling
- Share diff target resolution between
DiffViewerProvider and AgentManagerProvider
Priority 3: Process Spawn Reduction
- Consolidate
rev-parse calls into single invocations
- Consider persistent git subprocess instead of spawning new process per command
Key Files
src/agent-manager/GitOps.ts — Core git operations, poller logic
src/agent-manager/WorktreeManager.ts — Worktree lifecycle management
src/agent-manager/git-transfer.ts — Git state capture & apply
src/services/commit-message/index.ts — VS Code git API usage
src/KiloProvider.ts — Remote URL resolution
Problem
Users are reporting heavy system load caused by git processes spawned by the Kilo VS Code extension.
Root Cause Analysis
A comprehensive audit of all git invocation points in the codebase identified the GitStatsPoller (5-second polling interval) as the dominant source of sustained git process load.
Primary Culprit: GitStatsPoller (5s interval)
The
GitStatsPoller(instantiated inAgentManagerProviderconstructor) runs every 5 seconds when enabled (worktrees.length > 0 || panel !== undefined).Each poll cycle spawns multiple git processes per worktree:
git worktree list --porcelain— presence probegit rev-list --left-right --count— ahead/behind per worktreegit rev-parse(multiple calls) — branch resolution, tracking branch, remotegit config,git branch --show-current,git symbolic-ref— fallback chainsgit fetch— remote refresh (throttled to 120s, but resolution commands are not)With 3 worktrees: ~11 git processes every 5 seconds (~132/min)
With 5 worktrees: ~15 git processes every 5 seconds (~180/min)
Plus the CLI backend's own git processes triggered by
diffSummaryHTTP calls, easily exceeding 200+ git processes/minute.Secondary: Diff Polling (2.5s interval)
Both
DiffViewerProviderandAgentManagerProviderrun independent 2.5-second diff polling intervals when their panels are open, triggering additional git commands via the CLI backend.Key Issues
resolveTrackingBranch→resolveRemote→resolveDefaultBrancheach spawn multiple sub-commands without cachingLoad Summary
Recommended Fixes
Priority 1: GitStatsPoller Optimization
resolveRemote(),resolveTrackingBranch(),resolveDefaultBranch()results rarely change; cache with 60s TTLgit for-each-refor combine multiplerev-parsecalls into single process spawnsPriority 2: Diff Polling
setIntervalpollingDiffViewerProviderandAgentManagerProviderPriority 3: Process Spawn Reduction
rev-parsecalls into single invocationsKey Files
src/agent-manager/GitOps.ts— Core git operations, poller logicsrc/agent-manager/WorktreeManager.ts— Worktree lifecycle managementsrc/agent-manager/git-transfer.ts— Git state capture & applysrc/services/commit-message/index.ts— VS Code git API usagesrc/KiloProvider.ts— Remote URL resolution