Skip to content

fix(diagnostics): attribute background replication queries - #679

Merged
nixuuu merged 1 commit into
devfrom
perf/attribute-background-sql
Nov 13, 2026
Merged

nixuuu merged 1 commit into
devfrom
perf/attribute-background-sql

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Background mirror reads and owner overview feeds were counted as other, while configuration replication used the misleading settings.store family. Give these paths stable numeric families (mirrors.read, overview.feeds, config.sync) and preserve RPC context through their Effect boundaries. Label durable bot mirror replacements as mirrors.write.

Paired opt-in local workload: two linked desktop gateways with 12 threads each, desktop SSE, mobile Connect simulation, diagnostics enabled, 5 s warmup then 30 s idle. This changes attribution, not query frequency.

Diagnostics counter Before A / B After A / B
Database queries 2910 / 2623 2898 / 2623
Unclassified queries 210 / 150 30 / 30
GetComputers 12 / 0 12 / 0
AckThreadRange 6 / 6 6 / 6

Additional composed control, same clients/threads: leave the numeric collector/drain enabled but disable diagnostics persistence and peer collection. This records 821/761 queries per 30 s versus 826/765 with full collection, an observed difference of 5/4 (<1%). These short captures vary with minute boundaries; this separates SQL collection cost without claiming a CPU-overhead measurement. The remaining high-frequency work is background application reads.

After attribution: bots.store 1200/1200 executes, bots.queue 360/360, config.sync 360/288, mirrors.read 310/274; settings.store has zero new executes. Family counts are lower bounds because the existing collector SQL sub-budget saturates. The total query counter remains available. Diagnostics persistence itself accounts for 7/8 executes in this window; the background workload, rather than diagnostics history reads, dominates. Separate PRs address idle bot work and mirror/computer invalidations.

Validation: diagnostics gateway integration tests 11 passed, 101 assertions, including real range reads, owner overview subscription and aliases; paired workload passed; full typecheck and focused lint/format passed. Test resets its collector after the attribution fixture so optional-correlation pressure cannot affect the next test. Install, gen:check and web build passed during this task. Full local check:tmp deferred to CI because the shared host is overloaded; focused files ran through check:tmp with clean temp directories. No mobile/native sources changed; device checks remain blocked by the device host.

@nixuuu
nixuuu marked this pull request as ready for review November 13, 2026 23:19
@nixuuu
nixuuu merged commit 8a783c5 into dev Nov 13, 2026
11 checks passed
@nixuuu
nixuuu deleted the perf/attribute-background-sql branch November 13, 2026 23:43
nixuuu added a commit that referenced this pull request Nov 14, 2026
Repeated mirror commits published unchanged computer presence,
invalidating `GetComputers` and `ListWorkerRecords` in both desktop/web
and mobile shared caches. Compare computer content excluding
`lastSeenMs`; meaningful presence, name and sharing changes still
invalidate. Remove the configuration-notice timer and send invalidation
through the existing owner feed when the configuration clock or open
notices change (including dismissal and expiry).

Paired measurement on dev 7137e9a vs this branch: two real linked
desktop gateways, desktop SSE, mobile Connect client simulation, 12 idle
threads per gateway, diagnostics enabled, 5 s warmup then 30 s. The
opt-in `gateway-chatter.test.ts` emits the same RPC starts /
database-query counters as Diagnostics. No rendering or device
performance is inferred.

| Counter, 30 s | Before | After |
| --- | ---: | ---: |
| GetComputers, gateway A | 12 | 0 |
| Database queries, A | 2,910 | 2,748 |
| Database queries, B | 2,623 | 2,641 |
| WatchThread new openings during window | 0 | 0 |
| AckThreadRange, each gateway | 6 | 6 |

The after column was refreshed on the route-corrected head with the same
harness. GetComputers remains at zero new idle calls; the scoped route
lookup is included in the SQL totals.

The earlier composed seven-PR workload recorded 826/765 SQL queries per
30 s versus 2910/2623 on the baseline. That result predates the
independent review corrections and is historical, not a measurement of
the final combined heads. Use the refreshed independent measurements in
this PR and #678 for the corrected implementations. Collection-only
control is recorded in #679. These are idle local multi-client
measurements, not extrapolations of the production window.

Update timeout investigation: `LocalAppControl.check()` coalesces checks
and resolves normally after a 30 s soft wait if the desktop has not
acknowledged a newer check timestamp; it does not wait for an
installation. Linked requests use a separate 120 s check deadline and 15
min installation deadline. No confirmed hang was reproduced, so no
speculative update patch is included. An actual deadline failure in the
reported three requests cannot be distinguished from the soft wait using
durations alone. #669 adds no GetComputers polling.

Diagnostics itself remained enabled in both runs. Its dropped-detail
counters are still nonzero and are a separate issue; query totals are
exact in this workload. Setup/teardown is excluded. Reproduce with
`CANOPY_CHATTER_BENCH=1 bun run check:tmp
tests/integration/gateway-chatter.test.ts`.

Validation: bun install; gen:check; full typecheck; lint; format:check;
web build; shared-query-events tests; gateway overview-feed integration
tests (configuration revisions, resolved notices, owner isolation and
idle streams); paired workload through check:tmp with cleanup. All
commands used nice. The full local check:tmp suite was not run because
concurrent unrelated heavy suites already load the host; CI must cover
the full suite. Native mobile checks remain blocked by the reported
device-host error; no native/mobile source or fingerprint changes.

WatchThread verification of Related: #673: extended the existing
real-transport progress/drop regression to the mobile Connect client.
Both transports retain 1/2/4 s backoff across partial progress and stop
after resume/resume/stop. The focused thread-watch-failures suite passes
14 tests / 90 assertions, including premature clean EOF, oversized
frames and cursor repair. Normal desktop SSE and mobile foreground
streams stayed open through the 30 s idle workload (zero new openings).
No additional gateway close/GOAWAY defect was reproduced. The benchmark
now exposes collector allocation, all global SQL-family counters and
optional trace counts (`CANOPY_CHATTER_TRACE=1`).

Composed validation before review corrections: linked update integration
passed 13 tests / 112 assertions with clean check:tmp; typecheck, lint,
format:check, gen:check and web build passed with all seven fixes
applied. iOS and Android exports passed and native fingerprints remained
unchanged; device-host verification remains unavailable.

Independent review correction: computer overview events now include the
current owner-scoped route list, matching GetComputers snapshots. Manual
add/remove, authenticated route announcements and LAN discovery
therefore remain visible to the content comparison. A real
linked-gateway regression verifies cached routes refresh through
overview on manual add and remove without a name or presence change. It
fails against the old empty-route serialization and passes after the
correction (7 assertions, clean check:tmp). Shared-query events pass 8
tests / 25 assertions; gateway typecheck and focused lint/format pass.
The optional resolved-notice double read is unchanged.
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