You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Live monitoring showed the allocation rate is dominated by the main agent's own turns, not by subagent fan-out. During a main synthesis turn the GC rate burst to ~8.7 GC/s (≈131 GCs in one 15 s window), with ~4 GC/s on other main turns — and crucially these spikes occurred with active_runs{role=subagent} = 0, so it is not the children. Allocation rate jumped from ~2 MB/s idle to 40–53 MB/s during these turns.
Where the allocations come from
With store:false, every turn re-marshals the full accumulated conversation to the provider format; on top of that each turn does streaming chunk-decode and (mecatui-side) scrollback render. All three grow with conversation length, which is why the spikes land on the late, large main turns (synthesis over many prior subagent results).
Candidate hot paths to profile first:
Per-turn prompt/conversation assembly + marshal (grows with history; byte-stable-prefix caching helps the provider, not Go's re-marshal)
This is latent optimization, not a live problem: GC pauses stayed ≤ 262 µs p99 and GCCPUFraction ≈ 0.0005 (0.05% of CPU) throughout — GC absorbs the churn fine, and the session is model-bound (8.8% CPU). Reducing allocations will not speed up a normal session; the payoff is lower GC churn / steadier inter-token behavior on very long sessions. Treat as polish behind the correctness work (#152/#153).
Approach
Drive it from the offline harness, not live monitoring (live is non-deterministic and model-dominated):
task bench (+ the allocs-gate) and task perf:scenarios
memprofile → go tool pprof → benchstat A/B (the perf-optimization skill)
keep pure-perf changes byte-identical; mutation-test any cache guards
Acceptance
A ranked allocs/op attribution for the main-turn path (marshal vs decode vs render).
A benchstat-proven allocs/op reduction on the targeted site(s) with no behavior change.
A regression benchmark guarding the win.
Found via live perf monitoring (the alloc-rate spike correlated to sRun=0 main turns).
Activity
perf(adapter): benchmark per-turn request assembly to close the #157 …