Skip to content

fix(diagnostics): retain longer traces with reader export limits - #681

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

nixuuu merged 2 commits into
devfrom
perf/retain-diagnostics-traces

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

The user's 237-second trace filled its 2000-span ring and overwrote 112 sampled operations. Retain up to 10000 numeric samples (720000 B plus 16 B scratch) inside the unchanged separate 4 MiB opt-in trace ceiling. Sampling remains 1/101 operations and at most 100 samples/s; no new payload fields, timer, persistence or automatic collection.

Add an optional DiagnosticsTraceRequest.max_samples field and regenerate contracts. Web/mobile request 10000; absent/zero retains the legacy 2000 export limit through gateway, linked computer and WorkerLink. Export truncation counts as dropped samples without destroying the full local ring. Thus an older linked gateway's strict validator still accepts the result.

Paired 30 s local workload after 5 s warmup: two linked desktop gateways, 12 threads each, desktop SSE plus mobile Connect simulation, diagnostics and tracing enabled.

Diagnostics counter Before A / B After A / B
Database queries 2901 / 2619 2900 / 2621
Trace spans at end 105 / 80 109 / 80
Trace dropped samples 0 / 0 0 / 0

This short idle workload does not fill either ring; it verifies unchanged background work, not a drop reduction. A numeric synthetic workload matching the reported 2112 sampled operations over 237 s retains 2112 spans / 0 drops, versus the legacy export's 2000 spans / 112 drops. Saturated ring tests verify unique IDs, the 4 MiB encoded limit, stop/expiry cleanup and repeated GC plateaus (27 assertions).

Validation: real owner-scoped tracing integration suite 7 passed / 79 assertions, including both export limits through local, linked and worker routes; synthetic retention 9 assertions; memory suite passed. Install, full typecheck, lint, format:check and web build passed. Proto generation committed; gen:check rerun after commit. Full local check:tmp deferred to CI because the shared host is overloaded; focused files ran individually with clean temp directories.

Mobile iOS and Android exports passed. Native inputs unchanged: paired local fingerprints are identical before/after (iOS 74705db3a68907bc28379bb9b1080a227bc0755b, Android 7d38be8f5c9bf842d62060c75820a206f99c87e3). Device UI verification remains blocked by the reported device-host error. Request construction changes only; no visible UI/copy changes.

Fixes: #590

CI follow-up: the first full run passed 666 tests in the affected shard but failed the memory test's unchanged 2 MiB heap-delta bound. The expanded-ring test now warms a full 12-cycle window, including GC/expiry, before its baseline, and prints all cycle samples on failure. The revised local run passes 27 assertions: final stopped delta 743624 B and purged delta 23480 B. Both the 2 MiB absolute delta and 1 MiB purged plateau bounds remain unchanged; confirmation on CI is pending.

@nixuuu
nixuuu marked this pull request as ready for review November 13, 2026 23:43
@nixuuu
nixuuu merged commit b78180a into dev Nov 13, 2026
11 checks passed
@nixuuu
nixuuu deleted the perf/retain-diagnostics-traces branch November 13, 2026 23:44
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