Skip to content

fix(diagnostics): retain steady sql measurements within budget - #680

Merged
nixuuu merged 2 commits into
devfrom
perf/diagnostics-retention
Nov 13, 2026
Merged

nixuuu merged 2 commits into
devfrom
perf/diagnostics-retention

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Ordinary SQL family/RPC measurements exhausted a 512 KiB SQL allocation even while the 6 MiB process budget was mostly unused. The 192-correlation limit also counted global series, so startup metadata crowded out foreground RPC correlations. Reallocate internal measurements to 4 MiB, with SQL capped at 3 MiB, inside the unchanged 6 MiB total. Count only correlations toward a 256-series allowance: the composed workload with the new SQL families exceeded 192 despite substantial free budget. SQL completion still writes four numbers into the existing bounded queue; no new timer, query text or per-query object is added.

Add a time-weighted Dropped measurements per second gauge alongside the existing cumulative drop count. Suspension and wall-clock jumps do not invent observation time. Under adversarial cardinality the existing caps still drop explicitly and mark incomplete distributions.

Paired local workload: two linked desktop gateways with 12 threads each, desktop SSE plus mobile Connect simulation, diagnostics enabled; 5 s warmup then the same 30 s idle window.

Diagnostics counter Before A / B After A / B
Cumulative dropped measurements at end (includes fixture startup) 6411 / 2075 0 / 0
Drops during 30 s idle window 2679 / 0 0 / 0
Database queries during window 2910 / 2623 2888 / 2613
Collector allocation at end 869120 / 790800 B 991760 / 809312 B

Composed verification with all seven independent PRs: 826/765 queries per 30 s, zero new GetComputers calls, zero mirror ACKs and zero collector drops during that steady window. Startup still explicitly drops optional correlations beyond the per-slot cardinality cap (1464/1526 cumulative before the window); the new rate distinguishes this bounded startup detail from ongoing loss. The 256-series cap and unchanged total memory budget remain enforced. The final adversarial memory run passes 175 assertions with 0.21 MiB retained heap growth after warmup.

A deterministic 15-minute, 325-query/s workload records all 292500 queries: old collector drops 507395 measurements; new collector drops zero, with RPC correlations retained. This reproduces the failure without claiming a live device or a production 15-minute capture.

Validation: SQL retention/overflow/expiry/history/drop-rate unit tests 7 passed, 309 assertions; real linked workload passed. Saturated rolling-memory test retains the 6 MiB process ceiling and independent GC/heap plateau checks, with revised internal limits and slot-rotation tolerance. Install and full typecheck passed. Focused lint and formatting passed; gen:check/web build already passed earlier in the task. Full local check:tmp deferred to CI due shared-host load; focused integration files use check:tmp. Native/mobile sources and fingerprint unchanged; device checks blocked by the device host.

Copy audit (§8): absent rate label → Dropped measurements per second; explicit unit in a plain sentence-case diagnostic label, no action/error copy changed. No new colour or icon dependency.

Fixes: #535

@nixuuu
nixuuu marked this pull request as ready for review November 13, 2026 23:34
@nixuuu
nixuuu merged commit 8fa496d into dev Nov 13, 2026
12 checks passed
@nixuuu
nixuuu deleted the perf/diagnostics-retention branch November 13, 2026 23:44
nixuuu added a commit that referenced this pull request Nov 14, 2026
)

Diagnostics marked a computer with 14 of 15 minutes of coverage as “Not
enough data” whenever any measurement had ever been dropped. Restore can
legitimately shed older SQL details within its memory allowance; those
lifetime drops incorrectly affected every later range.

Use 75% coverage of the selected range for sufficiency. Show partial
measurements and suspended checks separately, with bounded reason codes
and expandable gap times/durations. Attribute restored-history eviction
to the evicted minute, expire losses with the selected window, and
persist genuine loss metadata through minute/hour rollups. Restarting
the gateway preserves the selected range and its saved measurements. The
four reported pickers already use the kit's custom button/listbox
Select; no native selects were found.

Fixes: #505
Related: #680

Validation:
- Passed install, gen:check, typecheck, lint, format:check, web build
and diff whitespace checks, using nice and /var/tmp for temporary files.
All GitHub checks are green.
- Focused gateway/history/hourly/SQL suites passed (33 tests), including
a real gateway restart with 60 minutes of persisted data and a 30-second
gap, retained sufficiency despite old-history shedding, persisted
SQL-loss reasons, and steady RPC/API collection with no limits flag.
Updated completeness/gateway suites passed again (13 tests).
- Additional linked-computer/worker suites initially passed 16 tests
with one offline-status readiness timeout. Rerunning the affected
linked-computer suite passed all 7 tests; that suite also passed in CI
on this head.
- Completed remote browser review in light/dark themes at desktop and
390px phone widths. Persisted coverage above 75% displayed “No issues
found” without a limits warning; expanded gaps showed measured
durations/times. A persisted SQL-buffer loss displayed “Partial data”
with its database-specific reason while retaining statistics. Long
computer names wrapped without horizontal overflow. All four pickers
rendered buttons/listboxes, with zero native select elements; desktop
popovers and phone sheets worked. Linked computers were covered by
integration tests rather than the single-home browser fixture.
- Removed the review stack, container, browser tab, tunnel and temporary
files after review.

Copy audit (§8):
- “Some measurements are missing. Limits were reached.” → specific
closed reasons (memory, database buffer, per-call series, coverage,
history, collection, saved history, links, response size or validation)
plus “Other measurements remain available.” Explains which measurements
are affected and why; older computers without reason metadata receive an
honest fallback.
- “Not enough data” at adequate coverage → “No issues found”, “Partial
data” or “Some checks are pending”, according to evidence. The
insufficient-data label remains below 75%.
- “No data during N periods.” → expandable period count plus “Gap of
{duration} at {time}.” Shows measured gaps without inventing an update
cause.
- Sentence case, short sentences, English glossary, no duplicated facts,
humour or colour-only meaning. No new action/confirmation/empty-state
copy. Desktop/phone, light/dark, typical and long-name checks completed.
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