Skip to content

Serialize fan-out EVENT frames once#1459

Merged
tlongwell-block merged 2 commits into
mainfrom
wren/w5-fanout-frame-once
Jul 2, 2026
Merged

Serialize fan-out EVENT frames once#1459
tlongwell-block merged 2 commits into
mainfrom
wren/w5-fanout-frame-once

Conversation

@tlongwell-block

Copy link
Copy Markdown
Collaborator

Summary

  • Cache live fan-out EVENT frames as immutable Arc<Bytes> per unique subscription ID within each fan-out cycle.
  • Send cached UTF-8 text bytes through ConnectionManager without changing existing string senders.
  • Keep frame construction strictly after filter_fanout_by_access; the persistent DM visibility owner fence is applied before frame caching too.

W5 fences

  1. Byte-identical frame: event_frame_for_sub preserves the old format!(r#"["EVENT","{}",{}]"#, sub_id, event_json) wire shape; unit test asserts String and Bytes equality against that legacy format.
  2. Cycle-scoped sharing: each fan-out call builds a fresh local HashMap<&str, Arc<Bytes>>; unit test asserts duplicate sub IDs share within one cache and a new cache gets a distinct Arc.
  3. No access widening: all three live fan-out paths build the cache only after filter_fanout_by_access returns; the persistent DM visibility owner gate is also applied before caching/sending.

Validation

  • bin/rustup run 1.95.0 cargo fmt --check
  • bin/rustup run 1.95.0 cargo test -p buzz-relay fanout_
  • bin/rustup run 1.95.0 cargo test -p buzz-relay
  • bin/rustup run 1.95.0 cargo clippy -p buzz-relay --all-targets -- -D warnings
  • pre-push hook with repo-local Hermit path: passed rust/desktop/mobile suites

Ships on 2df85d3f70459c529ceab67ccd26b25967107478.

npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 and others added 2 commits July 2, 2026 11:19
Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
* origin/main:
  perf(relay): bounded-concurrency multi-filter query execution (S2) (#1457)

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
@tlongwell-block tlongwell-block force-pushed the wren/w5-fanout-frame-once branch from e2f7e58 to 05563c2 Compare July 2, 2026 15:40
@tlongwell-block tlongwell-block merged commit 3c661fb into main Jul 2, 2026
29 checks passed
@tlongwell-block tlongwell-block deleted the wren/w5-fanout-frame-once branch July 2, 2026 18:31
wpfleger96 added a commit that referenced this pull request Jul 2, 2026
…n-metrics

* origin/main:
  feat: per-community workspace icon set by admins, served via NIP-11 (#1463)
  perf(relay): batch outbound websocket data frames (#1464)
  Make reaction ingest atomic (#1458)
  Serialize fan-out EVENT frames once (#1459)
  fix: agent reliability — no restart on channel-add, visible dead-letter notice (#1468)

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>

# Conflicts:
#	crates/buzz-relay/src/handlers/event.rs
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