zbus-old icon indicating copy to clipboard operation
zbus-old copied to clipboard

Limit outbound message queue

Open zeenix opened this issue 5 years ago • 1 comments

The following discussion from !194 should be addressed:

  • [ ] @sdroege started a discussion: (+1 comment)

    Yes :)


This should be configurable, just like the inbound queue in Connection.

zeenix avatar Dec 15 '20 21:12 zeenix

In GitLab by @danieldg on Aug 3, 2021, 02:40

If you want to use completely fair backpressure to limit the queue size, 71ff7c1977502fce695ae43b4fcf1112f0b6850f may need to be reverted because the Sink API requires implementing a reservation system but doesn't provide an API for cancelling a reservation. However, if you're fine with not handling byzantine edge-cases, you can provide "unfair" backpressure by checking the current queue size on poll_ready and then allowing start_send to "overfill" the queue.

For reference, if you create 100 threads (tasks don't have this particular race) that all call SinkExt::feed(item) on an outbound queue that can only fit one more message, and they all call poll_ready before any of them call start_send (because the OS scheduler hates you), then they will all see the same single open slot and put their item there.

zeenix avatar Aug 03 '21 00:08 zeenix