Communicate endpoint events in -proto w/ an intrusive queue #1650
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.
Work towards #1576, #599.
This replaces the requirement for callers to pass
EndpointEvent
s around with shared memory managed by the proto layer, using a purpose-built lock-free intrusive mpsc queue calledSharedList
. This simplifies the proto API and may be more efficient, although endpoint events are not typically on a hot path.Intensive review is required for the implementation of
SharedList
, which contains internal unsafety and relies on careful use of memory orderings for correctness. I couldn't find an off-the-shelf, well-audited data structure with similar semantics.Alternative approaches to this API change include a std mpsc channel and the pre-existing
EndpointEvent
enum, or an mpsc channel ofArc<EndpointEvents>
with an additionalAtomicBool
flag to minimize redundant messaging. These would avoid rolling our own data structure, at the cost using a more reviewed but needlessly complex and less specialized data structure. Further,SharedList
may prove useful elsewhere within quinn: a similar queue-once MPSC pattern exists in streams, and might be leveraged to increase application parallelism when performing stream I/O (see discussion in #1433).