Repository navigation
Cut the task list's cost under load: cap finished tasks, batch per-row work, skip no-op writes - #441
Merged
Merged
Conversation
…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
force-pushed
the
panopticon/dashboard-refresh-cost
branch
from
November 4, 2026 04:10
3befb74 to
879647b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 /taskstakesterminal_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.Dtoggles to all of them, and the footer counter shows when the cap is on._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.Cheaper per-row work (task service)
ArtifactStore.tasks_with_unhidden_artifacts) instead of a thread hop andscandirper row. The result is cached inTaskService, which is the store's only writer, andput_artifactupdates 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_statuses). Before, each row rescanned every registration and rebuilt the live-runner set.Fewer change-feed wakes
set_turn/set_blockedreturn without saving when the value is unchanged. The turn hooks fire on every prompt and every stop, so most calls are restatements.report_lifecycledoesn't notify when the phase, detail and runner are unchanged.Host daemon
Spawner.cleanupsettles a finished task with no checkout and no claim of ours by checking whether its workspace exists. Before, it forked adocker 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)
GET /tasks, full listGET /tasks?terminal_limit=50GET /tasksPatching 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-mixon the host will tell.🤖 Generated with Claude Code