Skip to content

v0.13.0 — Relay Optimization

Choose a tag to compare

@guan-tends guan-tends released this 15 Aug 01:22
· 114 commits to master since this release

Relay Optimization: Serialized Caching + Per-Key HAM + Batched Frames

Three Gun.js-inspired relay optimizations that reduce redundant work on the
network fan-out path. All transparent to the wire protocol.

Sprint 1: Serialized Message Caching

  • OnceLock<Bytes> on Put — serialize once, reuse for all peers (Arc refcount bump)
  • Mirrors Gun.js meta.raw

Sprint 2: Per-Key HAM Filtering

  • HamFilterResult enum (Stale / New / PartiallyNew)
  • Per-key timestamp filtering — stale keys dropped, only new keys relayed
  • Mirrors Gun.js ham() per-key inside while loop
  • Zero-alloc common case (all-new uses original &Put)

Sprint 3: Batched WebSocket Frames

  • handle_batch packs >1 messages into JSON array in single WS frame
  • Single-message sends unchanged — backwards compatible
  • Mirrors Gun.js peer.batch packing

Benchmark Results

Test v0.12.0 v0.13.0 Change
Relay 1 sender × 10k 5,287 msgs/sec 6,984 msgs/sec +32%
Relay 1 sender × 50k 10,643 msgs/sec 15,419 msgs/sec +45%
Relay 10 senders × 5k 11,380 msgs/sec 11,355 msgs/sec neutral

Test Summary

  • 358 native tests, 19 doctests, 7 WASM tests — all green
  • 0 clippy warnings