🤖 perf: throttle sub-agent projection refetches after usage-changed events

Abierto
#7,870 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript

Línea de trabajo

Start from the store code that refetches the open sub-agent projection on each usage-changed event, and from the getSubagentUsage call it makes. The issue names no files, so find them by searching for those identifiers. Add a per-ancestor trailing-edge throttle of about 1 s, or a backend view cache, then rerun the 200-writes-at-20/s benchmark with the parent shown and report fetch counts and CPU before and after. The second note, about the settling stream's ledger refetch double counting, needs a design decision first.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

After #7867, the store refetches the open sub-agent projection once per usage write for each ancestor shown on screen (single flight, no delay). An independent verifier measured the cost for a large tree:

  • One getSubagentUsage for 107 open sub-agents costs about 29 ms of server CPU (11 ms on the main thread).
  • 200 headless writes at 20/s with the parent shown cost 200 fetches and 9.16 s of server CPU over 11.6 s, against 2.10 s with the parent not shown.
  • The estimate is 11-22% of the backend main thread per window showing a large root at 10-20 usage events/s, about 30-60× more fetches than before #7867.

Fix: a per-ancestor minimum interval between projection fetches (about 1 s, trailing edge, so the last change always lands), or a per-sub-agent view cache on the backend. Acceptance: rerun the 200-writes-at-20/s benchmark with the parent shown, report fetches and CPU before and after, and keep totals exact.

A second note from the same verifier: a workspace's own headless spend (bash AI proxy, status titles) now shows only when that workspace's own stream ends. The store skips its own ledger refetch during its own stream to avoid counting the stream twice. The final total is correct. Fixing this needs a refetch that cannot double count the settling stream.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Lenguaje dominante
TypeScript
Estrellas
2.1k
Forks
139
Merge medio
4 h 38 min
PR fusionados (30 d)
926

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/xum

Todos los issues de coder/xum

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.