Repository navigation
perf(computers): invalidate shared reads only on changes - #675
Merged
Merged
Conversation
This was referenced Nov 13, 2026
nixuuu
marked this pull request as ready for review
November 13, 2026 23:05
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Caught-up thread mirrors performed an empty range read and durable ACK every five seconds. Use the existing heartbeat instead, and reuse the thread-head snapshot until the owner replication clock changes. Real batches retain the single outstanding batch, 64-record/64 KiB limits and ACK-after-commit contract. Debouncing those ACKs would stall this flow-control protocol. Fixes: #539 Paired local workload on dev 7137e9a: two linked desktop gateways, desktop SSE plus mobile Connect simulation, 12 idle threads each, diagnostics enabled, 5 s warmup then 30 s. Measured independently of the shared-cache fix in #675. The measurement harness is in #675; use the identical harness against both revisions. | Diagnostics counter, 30 s | Before | After | | --- | ---: | ---: | | AckThreadRange, A / B | 6 / 6 | 0 / 0 | | Database queries, A / B | 2,910 / 2,623 | 2,470 / 2,410 | | Unclassified queries, A / B | 210 / 150 | 126 / 90 | | GetComputers, A | 12 | 0 | | Foreground WatchThread openings during window | 0 | 0 | The GetComputers reduction follows removal of idle mirror commits; #675 also handles repeated presence during actual updates. Active ACK rates depend on real writes and retain the existing batching cadence. These idle numbers are not a throughput claim. Validation: check:tmp on thread-ranges (10 passing tests, including new idle heartbeat assertion, lost ACK/restart, ownership, gap repair, batch limits, live metadata and healthy unary); thread-range-move-controls; paired workload and cleanup; full typecheck; focused lint/format. Install, generation, full lint/format and web build were also checked in this task against the same dev base. Full local check:tmp is deferred to CI because unrelated heavy suites already load the host. No mobile/native code or fingerprint changes; device host remains unavailable.
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
The bot runtime opened delivery, routine and claim transactions every 250 ms even with no bot work. Add an owner-scoped preflight and skip empty transactions. Owners with no configured bots defer local bot readiness reads for up to five seconds. Linked-agent delivery checks run every 250 ms for all owners, including computers with no bots. Owners with bots retain one cheap readiness query every 250 ms, preserving responsiveness to cross-process queue/routine changes and model handoffs. Sends, retries, approval answers, configuration changes and unarchive wake immediately, including a wake racing an in-flight tick. Durable eligibility, locking, claim limits, fencing and ACK behavior are unchanged. The handoff implementation moved unchanged into its own module to keep the runtime below the repository's file-size limit. This removes empty multi-query transactions rather than claiming that configured bots no longer poll; eliminating their final readiness query requires a durable cross-process wake mechanism. Independent paired local measurement on dev 7137e9a: two linked desktop gateways, desktop SSE plus mobile Connect simulation, 12 idle threads each, diagnostics enabled; 5 s warmup, 30 s measured. Same measurement harness as #675, without the computer or mirror fixes. | Diagnostics counter, 30 s | Before | After | | --- | ---: | ---: | | Database queries, A | 2,910 | 1,462 | | Database queries, B | 2,623 | 1,187 | | GetComputers, A | 12 | 12 | | AckThreadRange, each gateway | 6 | 6 | | Foreground WatchThread new openings | 0 | 0 | The refreshed result includes the review correction that restores linked-agent checks every 250 ms on bot-less computers. It supersedes the earlier 1,230 / 954 result, which benefited from the incorrect five-second linked-delivery delay. Total SQL is 5,533 → 2,649 (about 52% fewer) in this idle local fixture; this is not an extrapolation of the user's production window. Validation: gateway bots integration (12 tests / 78 assertions: owner-scoped preflight, configured idle bot, lease deadlines/recovery, durable restarts, concurrent messages, exchanges, reminders, cancellation and approvals); bot-routines integration (10 tests / 144 assertions); paired workload through check:tmp and cleanup; full typecheck; full lint/format. Task-level install, gen:check and web build passed on the same dev base. Full local check:tmp is deferred to CI because unrelated heavy suites load the host. No mobile/native source or fingerprint changes; device host remains unavailable. CI exposed delayed cross-process handoffs/routine follow-ups under the initial broad idle delay. The existing bot-handoff suite passes 10 tests / 91 assertions and linked-agents passes 16 tests / 117 assertions, one file at a time locally through check:tmp. Independent review then identified linked-agent delivery on bot-less computers still sharing that delay; the review correction moves the idle gate after linkedTick and refreshes the measurement above. Review correction also removes the unused delay_ms calculation. Configured owners no longer schedule the next preflight after query completion (which skipped every other timer tick). Readiness follows the durable claim order, including waiting/live-running barriers; watches become ready only for terminal turns or resolvable steers. Wakeups and routines retain their due-time/enablement rules. New readiness/cadence/replay coverage passes 6 tests / 23 assertions; the concurrent-wake test has no polling timer to rescue a lost wake. Real linked-gateway tests with no bots deliver a completion report in 218 ms and a permission question in 76 ms (2 tests / 8 assertions, clean check:tmp). Both miss the 1.5 s delivery deadline against the previous runtime/poll implementation; the identical tests pass after the correction.
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated mirror commits published unchanged computer presence, invalidating
GetComputersandListWorkerRecordsin both desktop/web and mobile shared caches. Compare computer content excludinglastSeenMs; 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.tsemits the same RPC starts / database-query counters as Diagnostics. No rendering or device performance is inferred.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.