Skip to content

Cut the task list's cost under load: cap finished tasks, batch per-row work, skip no-op writes - #441

Merged
tildesrc merged 1 commit into
mainfrom
panopticon/dashboard-refresh-cost
Nov 4, 2026
Merged

tildesrc merged 1 commit into
mainfrom
panopticon/dashboard-refresh-cost

Conversation

@tildesrc

@tildesrc tildesrc commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

With ~850 finished tasks and 48 live agents on one host, every change-feed tick made each long-poller re-read and re-serialize the whole task list. The dashboard made it worse: it fetched the list twice per tick and rebuilt all ~858 rows each time. This is the follow-up to #437 (WAL mode) and #440 (dashboard resilience), and builds on #440's refresh error handling.

What changes

Fewer rows (dashboard + API)

  • GET /tasks takes terminal_limit=N. It returns every active task plus the N most recently updated finished task trees. Two kinds of finished task always survive the cap: a child of a still-active governor (the dashboard files it under that governor), and every member of a kept finished ensemble.
  • The dashboard asks for the newest 50 finished trees. D toggles to all of them, and the footer counter shows when the cap is on.
  • Refreshes go through Keep the dashboard running when a refresh fails #440's _refresh, which now takes an optional snapshot. It does the REST reads first: the task list only when it isn't already in hand, then the runner list. On an HTTP error it keeps the last-drawn table and warns once; on success it hands off to _render, which draws.
  • The dashboard draws the snapshot its long-poll already returned, instead of fetching the list again. When the rows it would draw match what's on screen, it leaves the table alone. A clock-only snooze repaint reuses the last snapshot.

Cheaper per-row work (task service)

  • The artifact mark is resolved in one batched scan (ArtifactStore.tasks_with_unhidden_artifacts) instead of a thread hop and scandir per row. The result is cached in TaskService, which is the store's only writer, and put_artifact updates the cache. A finished task's "no" is remembered; an active task's "no" is re-probed, because its agent or the operator may add a file at any time.
  • Container status is composed for the whole list in one pass (container_statuses). Before, each row rescanned every registration and rebuilt the live-runner set.

Fewer change-feed wakes

  • set_turn / set_blocked return without saving when the value is unchanged. The turn hooks fire on every prompt and every stop, so most calls are restatements.
  • report_lifecycle doesn't notify when the phase, detail and runner are unchanged.

Host daemon

  • Spawner.cleanup settles a finished task with no checkout and no claim of ours by checking whether its workspace exists. Before, it forked a docker ps (is_running) for every finished task on every host pass, which meant hundreds of forks per change.

Measuring

  • panopticon request-mix [LOG] tallies the service log (default /tmp/panopticon-service.log): writes vs long-polls vs full reads, plus the busiest write endpoints with ids folded out.

Numbers (in-process, 50 active + 850 finished tasks, 90% with a plan)

main this branch
GET /tasks, full list 104 ms 28 ms
GET /tasks?terminal_limit=50 – 19 ms
dashboard redraw per change (CPU) 130 ms (900 rows) + a second full GET /tasks 53 ms when a visible cell changed (100 rows); 7 ms when nothing visible changed

Patching only the changed cells (update_cell_at) measured the same as a 100-row rebuild, because the table's relayout dominates either way. So the dashboard either skips the redraw or rebuilds.

Not done: coalescing bursts of change-feed notifications into one wake. That's only worth it if the host's request mix shows bursts once the no-op writes are gone; panopticon request-mix on the host will tell.

🤖 Generated with Claude Code

…r-row work, skip no-op writes

On a host with ~850 finished tasks and dozens of live agents, every change-feed tick made each
long-poller re-read and re-serialize the whole task list, and the dashboard fetched it twice and
rebuilt every row.

- GET /tasks takes `terminal_limit`: the N most recently updated finished task trees (a finished
  child of an active governor, and every member of a kept finished ensemble, always survive). The
  dashboard asks for the newest 50; `D` shows them all.
- The dashboard draws the snapshot its long-poll already returned instead of fetching again, and
  leaves the table alone when the rows it would draw are the ones on screen.
- The list endpoint resolves the artifact mark in one batched scan, memoised in the service (the
  artifact store's only writer), and composes container statuses in one pass over registrations.
- set_turn / set_blocked / report_lifecycle no longer save or bump the change feed when they
  restate the current value (the turn hooks fire on every prompt and stop).
- The host daemon's cleanup settles a finished task with no checkout and no claim of ours with a
  stat, not a `docker ps` fork per finished task per pass.
- Folded into #440's refresh error handling: `_refresh(tasks=None)` makes the reads (only
  the runner list when the long-poll or the snooze timer already holds the tasks) and keeps the
  last-drawn table on failure; `_render` draws.
- `panopticon request-mix [LOG]` tallies the service log: writes vs long-polls vs full reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tildesrc
tildesrc force-pushed the panopticon/dashboard-refresh-cost branch from 3befb74 to 879647b Compare November 4, 2026 04:10
@tildesrc
tildesrc merged commit c3b068c into main Nov 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant