Redesign, cut CPU use ~70%, and add persistent history with UPS power events #1
Loading…
Reference in a new issue
No description provided.
Delete branch "redesign-perf-history"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Three changes, built in parallel and merged here:
Redesign: a printed instrument panel
datavizpalette rules in both themes.DESIGN.mdis rewritten.Performance: production uses ~18–22% CPU; this branch uses ~5–6%
docker psnow runs with--size=false. Without it, Docker computed every container's disk size on each call (334 ms → 27 ms).docker statsstream replaces a newdocker statsprocess every second./api/metrics. With 20 clients connected, CPU drops from 39% to 6%. Public-access filtering is unchanged, and a new test checks it.docker eventsinstead of restartingdocker logsevery second.Persistent history and UPS power events
src/history.rsstores samples at three levels of detail: raw for 1 h, 1-minute averages for 7 d, 15-minute averages for 90 d. Files are fixed-size records under about 2 MB, saved every 60 s and on SIGTERM, and survive a half-written last record.GET /api/history?range=1h|6h|24h|7d|30d|90dandGET /api/ups/events. Both followconfig/public-access.json.history-data:/app/datavolume (HISTORY_DIR).Also
compose.dev.ymlruns a separate dev preview (its own image, alias, history volume, and a read-only Compose mount).Behaviour changes
Testing
cargo fmt --checkandcargo testpass: 21 tests, including the new history, transition, persistence and public-filtering tests.tests/*.test.jspass, including the newhistory.test.js.Deploy notes
docker compose up -d --buildcreates the newhistory-datavolume. History starts empty, and power events begin recording after the first reading.🤖 Generated with Claude Code
Measured with a private replica of the production container on this host (same mounts and capabilities): idle 17-18% -> 6.0%; with 20 SSE clients 39.2% -> 6.1%; extra dockerd CPU caused by Hostwatch ~20% -> ~2%. - docker ps used --format '{{json .}}', which makes the CLI request container sizes, so the daemon walked every container's layers on each call (334 ms vs 27 ms). Pass --size=false (collector and project logs). - Replace a `docker stats --no-stream` per tick (2.1 s, ~0.5 s dockerd CPU each) with one long-lived streaming `docker stats`, publishing only complete refreshes. `docker ps` now runs every 2 s instead of ~3 s. - sysinfo refreshed every thread as a process (~3300 entries instead of ~840) on a 16-thread rayon pool, and re-read exe links. Upgrade to 0.38 (same API), drop default features (no rayon), refresh only cpu, memory and disk usage without tasks. Process list and count now exclude threads. - Rank processes before building JSON for the 100 published rows. - hwmon reads (it87 fans, drivetemp, nvme) took 35-330 ms per tick and stretched the collector period. Poll them on their own thread every 5 s. The collector now ticks on a steady 1 s interval. - Serialise each snapshot once per audience (admin/public) and share it across SSE and /api/metrics clients instead of filtering and encoding per client per tick. Output bytes are unchanged; a test checks that both encodings match visible_metrics. - Stopped project members in a log stream re-ran `docker logs` and `docker inspect` every second. They now wait on one idle `docker events` stream and reattach on start, ending when the container is destroyed. - Frontend: freeze log records so Alpine doesn't deep-proxy up to 1500 rows when the log filter runs on every batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>Containers stay as they were. Elsewhere, undo the parts of the last pass that hid cheap, useful detail. - Temperatures: CPU cores keep the summary line ("16 sensors · 44-66 °C · avg 57") and always show a compact grid of every core (label, short bar shaded by temperature, value). No toggle. Device rows gain a thin, quiet meter beside the hottest reading (hidden on phones, where long names now wrap). - Hardware: the per-core usage table is always visible under a calmer summary row, with tighter rows. - Overview: a thin per-core strip returns under the Activity chart with only a "Per core" caption. - Network: list every interface when there are eight or fewer; keep the virtual-interface toggle for busy hosts. "More columns" stays for the wide tables. - Update DESIGN.md and the screenshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>