Skip to content

Measure dashboard /api/state, /metrics, poll tick, CPU and memory with three arms #4217

Open

Description

@pithead-developer

What's the problem

There is no dashboard performance result. The /api/state history projection (copy, filter, bucket-average over up to about 86,400 rows, synchronous on the event loop) is suspected hot from a laptop replica (about 85 ms, order of magnitude only). The earlier baseline produced 1 to 5 eligible pairs of the 10 required per cell and the fixed-Python arm was never run. Poll-tick and per-worker scaling (unbounded probe fan-out, per-tick writes, share-list copies, PPLNS window scans) is never measured.

What it impacts

The only candidate for a Rust piece, the dashboard piece decision (fix Python, Go, or Rust), and the dashboard memory claim (about 0.06 GiB in a compose comment, 512m limit).

How I found it

Benchmark track data: five Python cells at 2, 50 and 100 rigs, 24 h history (not 30 days), 1 and 10 clients, none qualified; a descriptive smoke run showed peak RSS about 62 to 65 MB, which is not a baseline. Two confounds are recorded: seeded history ages during a run and the watcher cost CPU. Code read: handle_state runs build_state on the loop per request with no cache.

How important is it

High for the Go-vs-Rust call; no dashboard piece may ship on speed grounds without it. Not release-blocking.

Acceptance criteria

  • Arms A (current Python), B (Python with a caching or incremental-downsample fix), C (read-only Go prototype of the projection); conditional arm D (Rust prototype) runs only if both B and C miss the owner budget.
  • 2, 50 and 100 rigs, a pinned history fixture that does not age, 1 and 10 clients, 10 eligible pairs per cell or the cell is reported unqualified. The 30-day fixture is a new design choice versus the prior 24 h cells.
  • p50, p95 and p99 for /api/state and /metrics, event-loop block time, CPU and memory.current/peak.
  • With no HTTP clients: poll-tick duration, process CPU share and event-loop lag at 2, 50 and 100 rigs, plus a per-step profile of build_state, probe fan-out and share scans.
  • The report presents arms A to C with a recommended latency and memory budget, and the owner sets the budget from it; an ADR next to docs/dev/config-layer-language.md recommends fix Python, Go sidecar, Rust, or keep.

Possible solutions

Reuse the collector, orchestrator and interleaved-pair harness on go-port/3811-bench after fixing host-noise filtering and fixture aging. Build arm C from go/internal/dashboard charts, series and stateview. Unknown: how many rigs real deployments reach.

Release: date 2026-12-04
Who: operator

Activity

  1. added
    dashboard
    testing
    performance
    size:L
    on Nov 17, 2026
  2. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Data points for the baseline, from a read-only audit of develop at f6ddd449.

    DIY test server (12 threads, remote-node mode, no rigs connected, a few hours of history), so this is the idle floor:

    Laptop, synthetic 100 rigs and 30 days of history (order of magnitude only):

    Not measured: poll-tick cost by rig count, the 50-rig and 100-rig cells on server hardware, and the fixed-Python arm.

  3. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    A local three-arm measurement of the dashboard hot paths is in progress: the current Python, a fixed-Python arm, and compiled arms in C and Go, on fixtures of 2, 50 and 100 rigs with 30 days of history and a pinned clock. The harness and the results will be posted here. It runs on one laptop, so it gives ratios between arms, not the cells this issue asks for; those stay open.

    Owner direction, 24 November 2026: pull a part out into compiled code where it measurably performs better. A small, simple component may be C if it is tested properly; anything large is Rust.

  4. added
    operator-hold
    on Nov 24, 2026
  5. pithead-developer commented on Nov 25, 2026

    @pithead-developer
    ContributorAuthor

    Measured on 24 and 25 November 2026. Six arms answered the same requests from the same pinned data, taking turns in one session. A second pass rebuilt every arm from its sources and ran the numbers again; the figures below are from that second pass.

    Setup. develop as it stood on 24 November (version file 2.0.4), CPython 3.11, the dashboard's own aiohttp app, a history of about 80,000 rows, fleets of 2, 50 and 100 rigs. A development machine (arm64, macOS) under other load, not the Linux image. Identical code measured against itself differed by 0.98 to 1.06 at the median, so that is the noise floor.

    Default request, GET /api/state?range=all&avg=10m, about 283 KB of JSON, 100 rigs, nothing cached:

    Arm CPU per request Against today Longest stall of the event loop, 1 client / 10 clients
    Today 97 ms 1 123 ms / 1,225 ms
    Python: four fixes on the build path 45 ms 0.46 48 ms / 446 ms
    Python: the fixes, a cache per poll, and the build moved off the event loop 39 ms, or 0.3 ms when the cache answers 0.40, or 0.003 21 ms / 41 ms
    Compiled kernel in process, rows converted on each request 63 ms 0.65 76 ms / 581 ms
    Compiled kernel in process, columns kept by the poller, C 23 ms 0.24 29 ms / 236 ms
    The same in Go 28 ms 0.29 42 ms / 302 ms
    A separate Go process serving a reply the Python side builds on each poll 1.8 ms per request, plus 38 ms of Python per poll
    • The cost follows the number of history rows, not the number of rigs: 2, 50 and 100 rigs give the same picture.
    • /metrics: 31 ms today, 12 ms with the Python fix, 3.6 ms with the compiled kernel.
    • The poll tick costs 8.4 ms every 30 seconds at 100 rigs. Nothing compiled matters there.
    • JSON encoding is 3 to 4 ms of the 97. It is not the cost.

    Per day, one open tab plus the container health check, which requests HEAD /api/state every 30 seconds. These are computed from the readings above and the request pattern in the code, not measured over a day:

    Arm CPU-seconds a day
    Today about 600
    Python fixes without a cache about 275
    Separate Go process about 265
    Compiled kernel, Go about 175
    Compiled kernel, C about 165
    Python fixes with cache and off-loop build about 140

    With no tab open nothing hits the cache: the compiled kernel is then at about 96 and the Python arm at about 130.

    Same output. Every arm returned byte-identical bodies for all 87 reference requests (3 fleet sizes, 29 queries each). Two exceptions that are not about the body:

    • The separate process drops the security headers and the session-cookie refresh that the Python app adds, and it does not listen for up to 60 seconds on an empty history.
    • The cache serves a body up to one poll old for rows written between two polls (found blocks, raffle wins). Reproduced.

    Problems with the compiled kernel. With the native module switched on, five of the project's own test files crash the interpreter (exit status 139), for the C and the Go library alike. A mocked state object reaches the foreign-function call, and a wrong object becomes a crash instead of an exception. The kernel would also need a compiler in the image build, one build per architecture, and tests of its own for the coverage gate.

    Reading, for #4226. The Python route is the better buy at this scale:

    • With a tab open it costs less CPU per day than the compiled kernel.
    • It removes about 90% of the event-loop stall, which is the part a person notices.
    • It adds no build step and no second language to the dashboard.

    A compiled kernel would save at most about 110 CPU-seconds a day beyond the Python fixes without a cache, which is 0.13% of one core, and nothing once the cache is in and a tab is open. Rust was not measured; C and Go were equal within noise in process.

    Not measured: the Linux image, a real browser (focus and visibility events fire extra requests), a run over days, and how often a metrics scrape really happens.

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

    dashboardoperator-holdperformancesize:Ltesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions