Skip to content

Piece 9: dashboard /api/state projection (language decided by the measurement issue) #4226

Done

Description

@pithead-developer

What's the problem

handle_state builds the payload on the event loop per request, copying and bucket-averaging up to 30 days of in-memory history in Python, and /metrics repeats window averages per scrape. Whether this is a real problem is unmeasured.

What it impacts

Dashboard responsiveness (30 s browser polling, extra range fetches), metric scrapes, memory under a 512 MB cap.

How I found it

Code read of views.py, charts.py and metrics.py and a laptop replica of about 85 ms over 86,400 rows (order of magnitude only). No bench measurement or profile. Blocked on: #4217 (its result, and the budget the owner sets from it). Note handle_state also reads the poller's in-memory latest data and history, which are not in SQLite.

How important is it

Medium if the measurement confirms a miss; otherwise close as keep.

Acceptance criteria

  • The Python fix (arm B) is its own small PR whether or not a port follows, and is the default outcome.
  • If a sidecar is chosen, a written contract states what it reads and from where (SQLite only, or a snapshot the poller publishes) with a test proving a staleness bound, and where it runs (new Compose service or second process) with its mem_limit, healthcheck and egress rules given the read-only root, dropped capabilities and uid 1000.
  • Language follows the dashboard ADR; Rust only if the ADR records a measured miss by arms B and C.
  • Responses are identical for the existing dashboard suites at the release candidate with the selector in both positions.
  • Latency, CPU and memory.peak meet the owner budget; default flips in the release where all hold, otherwise it rolls.

Possible solutions

First: Python fix (cache by history version, incremental downsample, to_thread). If a port is needed: read-only Go (or Rust) sidecar behind PITHEAD_DASHBOARD_IMPL, reusing go/internal/dashboard charts, series, stateview and storage without the Python bridge. Cost: a second runtime in the image.

Release: PR pithead#4605 merged
Who: operator

Activity

  1. added
    enhancement
    dashboard
    performance
    size:L
    on Nov 17, 2026
  2. added
    operator-hold
    on Nov 25, 2026
  3. pithead-architect commented on Nov 27, 2026

    @pithead-architect

    Release regroom (owner request, 2026-11-27): removed the blocked-by link to #4217. #4217 posted its three-arm measurement on 11-25 and the choice it gates is made (PR #4605 cites it); its remaining cells do not block this issue.

  4. removed
    operator-hold
    on Dec 1, 2026
  5. pithead-developer commented on Dec 4, 2026

    @pithead-developer
    ContributorAuthor

    Closing: the Python arm landed in #4605 (merged 2026-11-28, merge commit 0786afe), and the measurement in #4217 chose that arm.

    Against the acceptance criteria:

    • Python fix as its own PR, the default outcome: met by Cut the dashboard's CPU per /api/state and /metrics request #4605. There is no selector, so the fix is simply the code path.
    • Sidecar contract: not applicable. No sidecar was chosen.
    • Language follows the dashboard ADR: met. It stays Python, and no ADR records a miss by arms B and C.
    • Identical responses: met for the existing dashboard suites and the 87 reference requests (3 fleet sizes x 29 queries), byte for byte. "Both selector positions" does not apply without a selector.
    • Owner budget: not checked. No budget was recorded here or on Measure dashboard /api/state, /metrics, poll tick, CPU and memory with three arms #4217. Measured on a 100-rig fixture: CPU per default /api/state went from 95 to 50 ms, range=1h from 44 to 16 ms, and /metrics from 27 to 9.5 ms, at about +4 MB peak RSS. If a budget is set later and this misses it, reopen.

    Models: claude-opus-5-5 (developer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dashboardenhancementperformancesize:L

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions