Repository navigation
v0.13.0 — Relay Optimization
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>onPut— serialize once, reuse for all peers (Arc refcount bump)- Mirrors Gun.js
meta.raw
Sprint 2: Per-Key HAM Filtering
HamFilterResultenum (Stale / New / PartiallyNew)- Per-key timestamp filtering — stale keys dropped, only new keys relayed
- Mirrors Gun.js
ham()per-key insidewhileloop - Zero-alloc common case (all-new uses original
&Put)
Sprint 3: Batched WebSocket Frames
handle_batchpacks >1 messages into JSON array in single WS frame- Single-message sends unchanged — backwards compatible
- Mirrors Gun.js
peer.batchpacking
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