opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Perf: cut worker-thread saturation/CPU from session diffs, snapshots, SQLite contention, and event fanout (PR #48638 series)

Open AceRothstein71 opened this issue 2 months ago • 3 comments

Context

Part of the fork hardening/perf series proposed in #48638 (integration branch session-diff-events, fork AceRothstein71/opencode). Original tracker: #49565.

PR #48638 is intended to close this issue.

Problem

Under concurrent sessions / parallel agents: worker-thread saturation from permission matching, turn-diff recomputation, event fanout to TUI/server clients, snapshot churn and snapshot-index recovery, and SQLite contention across sessions. Symptoms: stalled turns, high CPU, delayed diffs.

Change set (commit list, session-diff-events)

  • 41b33fee30 processor coalesce
  • 562dccf3c0 processor coalesce cleanup
  • fdb3778f95 audit findings: diff/events/sqlite
  • 857ce25bb8 doom-loop reload
  • c1fa9435ec wave 1-5 reliability
  • 15315be778 wave 6 residual
  • 56feb5c84e wave 7-11 hardening
  • 59c3e3280f sqlite lanes
  • 3d64416ba6 tui bridge sync
  • d84bbc617b session event-loop load
  • 6c1ddb3e4a snapshot heal
  • d27f83c334 snapshot index recovery
  • a38c279be3 vcs diff context
  • 2d1e6da481 core directory index
  • dc7e2ad448 wave G

Validation

  • Owner-observed: CPU usage is definitely lower under identical parallel-agent workloads.
  • Worker-thread stalls sharply reduced; turn-diff path bounded; mock-verified tool schema (206 tools, zero invalid required, zero empty combinators).

Linked: PR #48638 · tracker #49565 · sibling tracking issues listed in a follow-up comment.

AceRothstein71 avatar Sep 19 '26 13:09 AceRothstein71

Cross-links: sibling tracking issues #49974 (perf/runtime), #49975 (shell classifier H-L), #49976 (shell classifier M-P), #49977 (instance lifecycle), #49978 (MCP/schema), #49979 (server/SSE + event/db), #49980 (updater tooling). Integration PR: #48638. Original tracker: #49565.

AceRothstein71 avatar Sep 19 '26 13:09 AceRothstein71

Thanks for putting this together and for working on performance with many parallel agents.

As I understand it, you'd like to reduce worker-thread CPU use and stalls when many sessions or subagents run at once. The changes on your session-diff-events branch target permission matching, turn-diff recomputation, event fanout to TUI/server clients, snapshot churn and recovery, and SQLite contention. Maintainers will consider it. Since this is a broad set of changes, small focused PRs (one subsystem each), each with a workload others can rerun and before/after numbers, will be much easier to review than one integration branch.

Related items:

  • #49565: the original tracker for the same worker-thread saturation problem (closed by the bot for not using the issue templates)
  • #48638: the integration PR this issue refers to (currently closed)
  • #48641: event table bloat from repeated turn-diff payloads, which #48638 originally targeted
  • #42771: an earlier PR that also removed diff patches from event payloads
  • #49975, #49976, #49977, #49978, #49979, #49980: the sibling tracking issues for the other parts of the series

opencodejr[bot] avatar Oct 28 '26 10:10 opencodejr[bot]

This issue tracks the change set from #48638, and that PR was closed without merging, so I'm closing this along with its sibling trackers. If you can reproduce a specific stall or CPU spike under parallel agents on a current release, please open a focused issue with the workload and measurements, or send a small PR for one subsystem.

neriousy avatar Nov 19 '26 12:11 neriousy