Skip to main content

Performance

Zero-copy inbound frame feeding (#803) FrameDecoder in wacore-noise gains a new feed_bytes(Bytes) method that adopts an owned payload’s allocation wholesale instead of copying it into the internal staging buffer. In steady state — the WebSocket transport is message-oriented, so each message arrives on a clean frame boundary and the payload has no other references — Bytes::try_into_mut succeeds and the bytes are adopted without copying. The one remaining full memcpy of every inbound byte on the receive path is eliminated. Shared payloads (refcount > 1) and partial-frame leftovers fall back to the existing extend_from_slice path, so correctness never depends on the fast path firing. As a secondary benefit, each adopted payload is its own allocation. A node retained by the app (queued chat lane, Event::RawNode) now pins only its own WebSocket message’s bytes instead of holding a reference into a shared staging buffer alongside unrelated data. The main read_messages_loop has been updated to move the payload into feed_bytes instead of borrowing it for the old feed. The borrowing feed method is unchanged and remains available for the handshake path. No breaking changes. feed is unchanged; feed_bytes is additive.