Add ChannelSend trait to prep for lossy sender #4797
+43
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Gossip service consistently sees bursts in the millions of packets over the 2 second stat submission window.
The service currently uses
crossbeam_channel::unbounded
channels to buffer packets, which as the name implies, will unboundedly allocate space for incoming packets. The channel receivers will ultimately drop packets outside the bounds ofMAX_GOSSIP_TRAFFIC
.Summary of Changes
This PR introduces a trait,
ChannelSend
, which abstracts over a send side implementation of a channel. This lays the foundation for a follow up PR that will introduce a notion of a "lossy" channel sender. This implementation will wrap acrossbeam_channel::bounded
channel with a sender that will drop messages as channel capacity is reached rather than continuing to buffer messages until the receiver side is drained.This is introduced behind a trait bound due to the genericity of the
streamer
crate and the multi-purpose use of itsreceiver
implementation. In particular, this will allow gossip to use the aforementioned bounded / lossy sender without requiring other components like repair and fetch stage to use this forthcoming implementation.