Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
Run many Claude agents (5 to 8) in parallel on one server over several days, each in its own worktree, one long-lived orchestrator thread, keep the worktrees after the work is merged.
Expected behavior
- Settled threads (and the worktrees of finished, merged work) should not be polled by git; polling them on demand, or an opt-in cleanup of worktrees whose branch is merged and whose tree is clean, would keep the process count proportional to the active work.
- The state database should have a retention or compaction policy for old events and projections, and an incremental way to read the free-page count instead of PRAGMA freelist_count on a multi-GB file. A supported way to archive or retire a very long thread without losing the link targets of its child threads and PRs would also help.
- The per-turn process-table read should be throttled or shared (one poll for all turns, or a short TTL, or reading /proc directly) so its cost does not scale with concurrent turns.
- A host with 2 cores and 16 GB running a handful of agents should not be starved for minutes by server-side polling.
Actual behavior
On a small multi-agent host (2 cores / 16 GB, Linux under gVisor, t3 v0.1.11-nightly.20261119.4928, up to 8 live Claude agents, one long-lived orchestrator thread plus many short worker threads) the server load grows with history and with finished work, and the host froze three times in one day.
-
State database: statev2.sqlite is 6.6-6.9 GB.
t3 doctor --dry-runreports 6.86 GiB with only 607 MiB reclaimable, so compaction would not help much; the size is real history (about 6.0 M orchestration_events, about 434 k projection turn items, about 364 k nodes, about 61 k messages, plus an FTS table). About 870 SQL statements and about 500 transactions per minute; projection queries take 40-80 ms, sql.transaction averages 180 ms, PRAGMA freelist_count took up to 2.7 s. One long-lived thread holds about 18 k items and is the largest single load. -
Git polling of finished work: every thread gets a worktree and they stay after the work is merged. We had 656 worktrees (112 GB) and the server started about 1900 git child processes in 25 minutes, across worktrees whose threads were long settled.
-
Host freezes: server event-loop-stalls.ndjson shows event-loop stalls of 195 s, 222 s and 63 s within 55 minutes (with under 2 s of CPU in those windows, so the whole container was starved, not busy), after the load went up. In the two days before that there was one stall over 30 s.
-
pspolling per Claude turn (also reported in On macOS every open Claude session runs ps -A once a second, which floods endpoint security with process launches #37582): about 2ps -A -o pid=,ppid=,pgid=,lstart=spawns per second with only 3 active Claude agents.
Impact
Blocks work completely
Version or commit
t3 v0.1.11-nightly.20261119.4928
Environment
Linux, gVisor sandbox, 2 cores / 16 GB, no swap
Logs or stack traces
- Settled threads (and the worktrees of finished, merged work) should not be polled by git; polling them on demand, or an opt-in cleanup of worktrees whose branch is merged and whose tree is clean, would keep the process count proportional to the active work.
- The state database should have a retention or compaction policy for old events and projections, and an incremental way to read the free-page count instead of PRAGMA freelist_count on a multi-GB file. A supported way to archive or retire a very long thread without losing the link targets of its child threads and PRs would also help.
- The per-turn process-table read should be throttled or shared (one poll for all turns, or a short TTL, or reading /proc directly) so its cost does not scale with concurrent turns.
- A host with 2 cores and 16 GB running a handful of agents should not be starved for minutes by server-side polling.Screenshots, recordings, or supporting files
No response
Workaround
No response
Activity
RayFungHK commentedon Nov 23, 2026
Follow-up with measurements on
v0.1.12-nightly.20261121.5051(same host class: 2 cores / 16 GB, Linux under gVisor, up to 10 live Claude agents), plus thanks for #37585.1. Process-table reads (#37582 / #37585). Thank you, the shared poll in #37585 is the right shape. For reference, on the host above a small in-process memo of the table read (TTL 5 s) plus a 3 s cache in front of
pstook the spawn rate from about 237/min (stock, one idle fake CLI per session) to 12/min, and the server's own CPU at 10 agents was 3 to 11 % of one core, so after the fix the server is no longer the main consumer there.2. Shell stream. Every shell subscriber re-reads the shells of the threads that changed, once per
groupedWithin(512, 50 ms)window (toShellStream). In a controlled run (one subscriber acking like the UI, one fake turn emitting 80 assistant messages 20 ms apart) widening the window to 500 ms cut shell frames from 30 to 5,projectShellItemscalls from 31 to 5 andgetThreadShellfrom 38 to 12, and the final state was still delivered. A configurable (or adaptive) window would help hosts with many sessions.3. State database size (what is in it). 6.86 GiB file, 0.97 GiB of it free pages that never go back to disk because
auto_vacuumisnone. Live data 5.77 GiB:projection_turn_items58 % (2.2 GiB of payload JSON: dynamic_tool 1.1, command_execution 0.57, reasoning 0.30),projection_nodes21.5 %,orchestration_events9 %, turn positions 3.6 %, messages 2.6 %, FTS 0.9 %. About 0.2 GiB/day growth with about 10 agents. Two suggestions: (a) the onlineincremental_vacuummaintenance only helps whenauto_vacuum=INCREMENTAL; the databases created before that setting stay onnoneforever, so setting it at creation / in a migration (and havingdoctor --fixconvert existing databases, which it already does) would make the online job effective; (b) the real size lever is retention of the payload JSON of finished threads (tool output and reasoning), not the event table.4.
t3 doctor --fix. On a copy of that database it took 1 min 35 s (rewrite 1:28, search rebuild 0:07),quick_checkok,auto_vacuumbecame incremental, identical row counts, FTS rebuilt and queryable; 6.86 to about 5.8 GiB. One caveat for supervised servers: the in-app reclaim stops the server first, and a supervisor with a short stop timeout (we had 4 s) will SIGKILL the process group before the compaction finishes. A note in the docs, or a lock that makesdoctorrefuse to run when a stop was not graceful, would prevent a half-finished run.5. Writer. Tail latency of the commit batch (6,197 flushes): only 5 over 1 s; the slow ones coincide with host CPU starvation (median host idle 29 % at slow flushes vs 57 % over all), not with writer-lock waits (17 % of the time inside the slow flushes). So we are not asking for a change there.
Happy to share the scripts for the measurements (read-only trace analysis,
VACUUM INTOon a copy) if useful.juliusmarminge commentedon Nov 23, 2026
#37585, now on main: Claude descendant tracking now shares one periodic process-table read across live sessions, fixing the reported polling cost that scaled with concurrent agents.
Not done: The issue still asks for reduced git polling of finished worktrees, database retention and cheaper free-page inspection, and relief from host starvation; this merge does not implement those changes.
Closing; open a new issue if what is left still matters to you.