-
-
Notifications
You must be signed in to change notification settings - Fork 136
transport and messaging perf review #4241
Copy link
Copy link
Open
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionA-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-hardExperience needed to fix/implement: Hard / a lotExperience needed to fix/implement: Hard / a lotT-enhancementType: Improvement to existing functionalityType: Improvement to existing functionality
Metadata
Metadata
Assignees
Labels
A-contractsArea: Contract runtime, SDK, and executionArea: Contract runtime, SDK, and executionA-networkingArea: Networking, ring protocol, peer discoveryArea: Networking, ring protocol, peer discoveryE-hardExperience needed to fix/implement: Hard / a lotExperience needed to fix/implement: Hard / a lotT-enhancementType: Improvement to existing functionalityType: Improvement to existing functionality
Type
Fields
Give feedbackNo fields configured for issues without a type.
1 -
Bytesfor payloads: make operation clones O(1)Location:
crates/core/src/message.rs,crates/core/src/operations/Problem: Operation messages (
PutMsg,GetMsg,SubscribeMsg) carry contract state asVec<u8>. Cloning an operation (per hop in relay chain) deep-copies the entire payload — full alloc + memcpy. For 500 KB state: ~500 µs + 500 KB alloc per clone.Fix: Replace
Vec<u8>withbytes::Bytes(already a dep).Bytes::clone()is an atomic refcount increment (~0.1 µs). Requires#[serde(with = "bytes::serde")]on fields.Gain: Clone 500 KB: ~500 µs → ~0.1 µs (~5000×). Forward to 3 peers: 1.5 MB alloc → 3 refcount bumps.
Effort: High (architectural, days). Coordinate with in-flight PRs.
2 — Congestion window busy-poll: replace with
tokio::sync::NotifyLocation:
crates/core/src/transport/peer_connection/outbound_stream.rs:132-194Problem: When BBR congestion window is full, send task busy-polls: 10×
yield_now()(immediate re-queue), then 100 µs sleep, then 1 ms sleep. Under congestion at 1 Mbps: 7–30 ms/s CPU burned in polling.Fix: Add
tokio::sync::Notifyto congestion controller. ACK path callsnotify_one(), sender callsnotified().await. Zero polling, instant wakeup.Gain: Under congestion: 7–30 ms/s CPU → ~0 ms/s. Light load: unchanged.
Effort: Medium (2–3 hr). Wire
notify_one()into ACK path. No new deps.