Problem
Network event channel has fixed capacity with no backpressure:
// crates/node/src/run.rs:94
channel_size: 1000, // Fixed capacity
// crates/node/src/network_event_channel.rs:52
channel_size: 1000, // Default
Impact:
- If channel fills, new events may be dropped
- No signal to slow down senders
- Burst patterns can cause loss
Proposed Solution
- Add sender-side backpressure:
pub struct BackpressuredSender {
inner: mpsc::Sender<NetworkEvent>,
high_water_mark: usize, // Start backpressure at 80%
low_water_mark: usize, // Release backpressure at 50%
backpressure_active: AtomicBool,
}
impl BackpressuredSender {
pub async fn send(&self, event: NetworkEvent) -> Result<(), SendError> {
// Check capacity and apply backpressure delay if needed
if len > self.high_water_mark {
self.backpressure_active.store(true, Ordering::Relaxed);
tokio::time::sleep(Duration::from_millis(10)).await;
}
self.inner.send(event).await
}
}
- Add metrics for channel health
Acceptance Criteria
Priority: P3 (Low Impact, Medium Effort)
Problem
Network event channel has fixed capacity with no backpressure:
Impact:
Proposed Solution
Acceptance Criteria
Priority: P3 (Low Impact, Medium Effort)