Add async backpressure API for networking stack#188
Add async backpressure API for networking stack#188okhsunrog wants to merge 1 commit intojamesmunns:mainfrom
Conversation
b323f75 to
e0b3751
Compare
| if any_good { | ||
| Ok(()) | ||
| } else if any_full { | ||
| Err(InterfaceSendError::InterfaceFull) |
There was a problem hiding this comment.
not sure about the behavior and priority of return values here.
when there are multiple links and the second one fails, the result will be 'Ok' and the 'Full' state of the second or remaining ones is lost.
There was a problem hiding this comment.
This is actually pre-existing behavior in the non-wait send/send_raw methods (the any_good / any_full priority logic). When at least one edge succeeds, the result is Ok(()) and any InterfaceFull from other edges is silently dropped. The _wait variants inherit the same behavior.
This is arguably correct for broadcasts — they're best-effort ("flood" style). If one edge is congested, the message still reached the other edges and any local sockets. Changing this would require tracking partial delivery state across a retry loop, which adds significant complexity for a case that rarely occurs in practice
(all downstream consumers congested simultaneously).
| if any_good { | ||
| Ok(()) | ||
| } else if any_full { | ||
| Err(InterfaceSendError::InterfaceFull) |
|
The PR is quite large, I got a bit lost in my very brief look just now, was wondering if there is an example that highlights how the wait behavior can be used. that would go a long way to understanding this PR better rather before I look at the implementation details. |
Introduce ProfileBackpressure trait with send_*_with_wait methods that return SendOutcome::Wait when the output queue is full, allowing callers to await and retry instead of dropping messages. Add async public API methods on NetStack (send_ty_wait, send_raw_wait, etc.) and Topics (broadcast_wait, etc.) that automatically handle the wait-and-retry loop. Enable embedded toolkits to use backpressure by passing an optional queue handle to Sink::new(). Update all embedded toolkit constructors and demo applications. Fix broadcast routing to properly return InterfaceFull when all interfaces are full instead of NoRouteToDest.
e0b3751 to
0a4973a
Compare
|
@hydra Added doc comments with usage examples on |
Introduce
ProfileBackpressuretrait withsend_*_with_waitmethods that returnSendOutcome::Waitwhen the output queue is full, allowing callers to await and retry instead of dropping messages.Add async public API methods on NetStack (
send_ty_wait,send_raw_wait, etc.) and Topics (broadcast_wait, etc.) that automatically handle the wait-and-retry loop.Enable embedded toolkits to use backpressure by passing an optional queue handle to Sink::new(). Update all embedded toolkit constructors and demo applications.
Fix broadcast routing to properly return
InterfaceFullwhen all interfaces are full instead ofNoRouteToDest.