fix(desktop): cut steady-state relay traffic from polls and read-state echo - #5879
Merged
Conversation
…e echo A per-kind byte tap on a live desktop (~500 channels, large agent fleet) showed the top three inbound traffic sources were self-inflicted: - kind 30078 read-state (34% of bytes): our own ~44 KB encrypted blob, published on a 5 s debounce while reading, echoed straight back by the live subscription and nip44-decrypted + re-parsed each time - kind 30030 emoji union (33%): 2-minute poll backstop refetching every member's full set (~300 KB burst) with the live sub already covering freshness - kind 30175 persona catalog (13%): same 2-minute backstop pattern, ~150 KB per walk CPU tracked the bursts directly: 3-5% in quiet 10 s buckets vs 44-54% in buckets containing a poll burst or read-state echo. Changes: - ReadStateManager remembers the ids of events it just published (FIFO set, capped at 64) and drops their relay echoes before the decrypt/ parse step. Ids are recorded before publish so an early fan-out can't race the OK; the drop consumes the id, so reconnect replays of the same event still parse normally. - Emoji and persona poll backstops stretched from 2 to 20 minutes. The live subscriptions (invalidate on any new 30030/30175) and reconnect invalidations remain the freshness paths; the poll only covers a silently dropped live event. - localStorage identity helpers extracted to readStateIdentity.ts (mechanical move, no behavior change) to keep readStateManager.ts within the file-size ratchet. Tests: echo-drop before decrypt (mutation-checked), replayed-duplicate and foreign-client events still parse, published-id set stays capped when publishes fail. Full desktop suite 4794/4794, tsc and biome clean. Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Signed-off-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
wesbillman
approved these changes
Aug 14, 2026
tlongwell-block
pushed a commit
that referenced
this pull request
Aug 14, 2026
Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Signed-off-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> * origin/main: (67 commits) Projects v3: unify sharing, discussions, and issue ownership (#5792) chore(release): release Buzz Desktop version 0.5.12 (#5903) fix(mobile): unwrap batched observer telemetry (#5805) perf(desktop): update active turns incrementally (#5897) fix(link-previews): send while previews finish in background (#5697) fix(desktop): cut steady-state relay traffic from polls and read-state echo (#5879) fix(desktop): support channel message path links (#5889) feat(mobile-messages): render compact Buzz permalink chips (#5639) test(desktop): await channel E2E bridge readiness (#5886) fix(link-preview): refetch a link when it re-enters the composer (#5510) feat(desktop-messages): render compact Buzz permalink chips (#5638) Fix video comment effect wrapping (#5748) Teach agents to inherit Buzz product intent (#5875) feat(desktop): one relative date ladder across chat and the Inbox (#3769) fix(desktop): amortize observer journal eviction with a low-water mark (#5808) Unify agent profile content (#5788) Standardize settings section layout (#5855) fix(desktop): share one timer across same-interval useNow consumers (#5861) Clarify immediate spoken huddle replies (#5863) Scope desktop presence subscriptions to active demand (#5830) ... Signed-off-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz>
wpfleger96
pushed a commit
that referenced
this pull request
Aug 14, 2026
…ties-manifest * origin/main: (35 commits) chore(release): release Buzz Desktop version 0.5.12 (#5903) fix(mobile): unwrap batched observer telemetry (#5805) perf(desktop): update active turns incrementally (#5897) fix(link-previews): send while previews finish in background (#5697) fix(desktop): cut steady-state relay traffic from polls and read-state echo (#5879) fix(desktop): support channel message path links (#5889) feat(mobile-messages): render compact Buzz permalink chips (#5639) test(desktop): await channel E2E bridge readiness (#5886) fix(link-preview): refetch a link when it re-enters the composer (#5510) feat(desktop-messages): render compact Buzz permalink chips (#5638) Fix video comment effect wrapping (#5748) Teach agents to inherit Buzz product intent (#5875) feat(desktop): one relative date ladder across chat and the Inbox (#3769) fix(desktop): amortize observer journal eviction with a low-water mark (#5808) Unify agent profile content (#5788) Standardize settings section layout (#5855) fix(desktop): share one timer across same-interval useNow consumers (#5861) Clarify immediate spoken huddle replies (#5863) Scope desktop presence subscriptions to active demand (#5830) Polish mobile profiles, DMs, and sheets (#5401) ... Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
wpfleger96
pushed a commit
that referenced
this pull request
Aug 14, 2026
…arer-auth * origin/main: (34 commits) fix(ci): read Playwright version without nested shell quoting (#5910) fix(desktop): restore the agent trading-card mint button (#5900) Projects v3: unify sharing, discussions, and issue ownership (#5792) chore(release): release Buzz Desktop version 0.5.12 (#5903) fix(mobile): unwrap batched observer telemetry (#5805) perf(desktop): update active turns incrementally (#5897) fix(link-previews): send while previews finish in background (#5697) fix(desktop): cut steady-state relay traffic from polls and read-state echo (#5879) fix(desktop): support channel message path links (#5889) feat(mobile-messages): render compact Buzz permalink chips (#5639) test(desktop): await channel E2E bridge readiness (#5886) fix(link-preview): refetch a link when it re-enters the composer (#5510) feat(desktop-messages): render compact Buzz permalink chips (#5638) Fix video comment effect wrapping (#5748) Teach agents to inherit Buzz product intent (#5875) feat(desktop): one relative date ladder across chat and the Inbox (#3769) fix(desktop): amortize observer journal eviction with a low-water mark (#5808) Unify agent profile content (#5788) Standardize settings section layout (#5855) fix(desktop): share one timer across same-interval useNow consumers (#5861) ... Signed-off-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> # Conflicts: # CHANGELOG.md
This was referenced Aug 17, 2026
morgmart
added a commit
that referenced
this pull request
Aug 17, 2026
…graphy-staging * origin/main: (41 commits) docs: refresh agent development guidance (#6049) feat(mobile): require device authentication for identity export (#5116) fix(desktop): hide the offcanvas-collapsed sidebar so it stops painting over the community rail (#5947) Polish mobile message threads and composer (#5645) chore(release): release Buzz Desktop version 0.5.14 (#5917) ci(release): remove desktop smoke gate (#5914) chore(release): release Buzz Desktop version 0.5.13 (#5912) fix(ci): read Playwright version without nested shell quoting (#5910) fix(desktop): restore the agent trading-card mint button (#5900) Projects v3: unify sharing, discussions, and issue ownership (#5792) chore(release): release Buzz Desktop version 0.5.12 (#5903) fix(mobile): unwrap batched observer telemetry (#5805) perf(desktop): update active turns incrementally (#5897) fix(link-previews): send while previews finish in background (#5697) fix(desktop): cut steady-state relay traffic from polls and read-state echo (#5879) fix(desktop): support channel message path links (#5889) feat(mobile-messages): render compact Buzz permalink chips (#5639) test(desktop): await channel E2E bridge readiness (#5886) fix(link-preview): refetch a link when it re-enters the composer (#5510) feat(desktop-messages): render compact Buzz permalink chips (#5638) ... Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> # Conflicts: # desktop/src/features/home/ui/InboxListPane.tsx # desktop/src/features/home/ui/InboxMessageRow.tsx # desktop/src/features/messages/ui/MessageAgentOwner.tsx # desktop/src/features/settings/ui/SettingsOptionGroup.tsx # desktop/src/features/settings/ui/SettingsPanels.tsx
bhargavms
pushed a commit
to EWA-Services/buzz
that referenced
this pull request
Aug 18, 2026
…e echo (block#5879) ## Problem Desktop webview CPU stayed high after the presence-scope fix (block#5830) and the shared useNow ticker (block#5861). A per-kind byte tap hot-patched into `relayClientSession.ts` on a live desktop (~500 channels, large agent fleet; 850 s capture correlated with CPU sampling) showed the remaining steady-state relay traffic is mostly self-inflicted: | kind | what | share of inbound bytes | shape | |------|------|-----------------------|-------| | 30078 | read-state | **34%** | our own ~44 KB nip44 blob echoed back every ~10-30 s while reading | | 30030 | emoji union | **33%** | 2-min poll refetching every member's full set (~300 KB burst) | | 30175 | persona catalog | **13%** | same 2-min backstop pattern, ~150 KB per walk | CPU tracked the bursts directly: 3-5% in quiet 10 s buckets vs 44-54% in buckets containing a poll burst or read-state echo. (The kind-24200 observer-frame theory was tested and disproven by the same tap: 9.7% of bytes, steady trickle.) ## Outcome - **Read-state echo drop.** `ReadStateManager` remembers the ids of events it just published (FIFO set capped at 64) and drops their relay echoes before the nip44-decrypt + `JSON.parse` step. Ids are recorded *before* publishing so relay fan-out can't race the OK. The drop consumes the id, so a reconnect replay of the same event still parses normally. Events from other clients of the same pubkey are untouched. - **Poll backstops stretched 2 min → 20 min** for the emoji union and persona catalog queries. The live subscriptions (invalidate on any new 30030/30175) and the reconnect invalidations remain the freshness paths; the poll only exists to cover a silently dropped live event. Behavior on publish, focus, and reconnect is unchanged. - Mechanical: localStorage identity helpers moved to `readStateIdentity.ts` (no behavior change) to keep `readStateManager.ts` under the file-size ratchet. Expected effect on the measured profile: the poll stretch cuts the 30030/30175 bursts (46% of inbound bytes) by 10x; the echo drop removes the recurring ~44 KB nip44-decrypt + parse per publish cycle (the echo still arrives on the wire — nostr filters cannot exclude own-author events — so this is a CPU/IPC saving, not a bandwidth one). ## Acceptance - New tests: echo dropped **before** decrypt (mutation-checked: disabling the drop fails the test), replayed duplicate of the same id still parses, foreign-client events always parse, published-id set stays capped when publishes fail (never-echoed ids). - Full desktop suite **4794/4794**, `tsc --noEmit` clean, `pnpm check` (biome + ratchets) clean at head. ## Not addressed (follow-ups) - The 44 KB blob itself (one read-state event carries all ~500 channels; a delta or per-channel-shard format is a protocol change). - Duplicate delivery of the same events on concurrent `history-` subscriptions (relay/client dedupe). - Webview RSS of 12.5 GB observed on the same machine — retention hunt is separate work; shrinking the heap multiplies the value of this PR since the GC floor scales with live-heap size. Signed-off-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@buzz.block.builderlab.xyz> Signed-off-by: bhargavms <bhargav.m@ewa-services.com>
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.
Problem
Desktop webview CPU stayed high after the presence-scope fix (#5830) and the shared useNow ticker (#5861). A per-kind byte tap hot-patched into
relayClientSession.tson a live desktop (~500 channels, large agent fleet; 850 s capture correlated with CPU sampling) showed the remaining steady-state relay traffic is mostly self-inflicted:CPU tracked the bursts directly: 3-5% in quiet 10 s buckets vs 44-54% in buckets containing a poll burst or read-state echo. (The kind-24200 observer-frame theory was tested and disproven by the same tap: 9.7% of bytes, steady trickle.)
Outcome
ReadStateManagerremembers the ids of events it just published (FIFO set capped at 64) and drops their relay echoes before the nip44-decrypt +JSON.parsestep. Ids are recorded before publishing so relay fan-out can't race the OK. The drop consumes the id, so a reconnect replay of the same event still parses normally. Events from other clients of the same pubkey are untouched.readStateIdentity.ts(no behavior change) to keepreadStateManager.tsunder the file-size ratchet.Expected effect on the measured profile: the poll stretch cuts the 30030/30175 bursts (46% of inbound bytes) by 10x; the echo drop removes the recurring ~44 KB nip44-decrypt + parse per publish cycle (the echo still arrives on the wire — nostr filters cannot exclude own-author events — so this is a CPU/IPC saving, not a bandwidth one).
Acceptance
tsc --noEmitclean,pnpm check(biome + ratchets) clean at head.Not addressed (follow-ups)
history-subscriptions (relay/client dedupe).