Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multitask quic socket operations #611

Closed
wants to merge 3 commits into from

Conversation

sakridge
Copy link

@sakridge sakridge commented Apr 5, 2024

Problem

quinn uses a single task to do socket operations. not great

Summary of Changes

use SO_REUSEPORT to fanout socket operation to multiple quinn::Endpoints

Fixes #

@sakridge sakridge marked this pull request as ready for review April 5, 2024 18:03
@@ -185,8 +224,37 @@ async fn run_server(
stats.clone(),
coalesce,
));

let mut accepts = incoming

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some comments please on what we are trying to achieve.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut accepts = incoming
// Create the set of accept() futures we're going to listen on for connections. We wrap quinn's
// incoming.accept() so we can store the endpoint index in EndpointAccept::endpoint. When a
// future resolves, we use the index to call incoming[index].accept() again. This way we don't
// have to recreate the whole set of accept() futures at every loop iteration, saving wakeups
// and tokio runtime work.
let mut accepts = incoming

@sakridge sakridge requested a review from lijunwangs April 5, 2024 19:35
@@ -275,6 +275,9 @@ mod tests {
)
.unwrap();

let response_recv_endpoint = response_recv_endpoints

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly related to this PR because pre-change the test is doing the same,
but: why is it using one of the server endpoints? Why isn't it creating a new
endpoint? Makes the test confusing - I had to triple check that it's fine to
just pick one from the now multi-endpoints.

Maybe add a comment that explicitly says that it doesn't really matter which
endpoint is used?

@@ -185,8 +224,37 @@ async fn run_server(
stats.clone(),
coalesce,
));

let mut accepts = incoming

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut accepts = incoming
// Create the set of accept() futures we're going to listen on for connections. We wrap quinn's
// incoming.accept() so we can store the endpoint index in EndpointAccept::endpoint. When a
// future resolves, we use the index to call incoming[index].accept() again. This way we don't
// have to recreate the whole set of accept() futures at every loop iteration, saving wakeups
// and tokio runtime work.
let mut accepts = incoming

let timeout_connection = select! {
ready = accepts.next() => {
if let Some((connecting, i)) = ready {
accepts.push(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
accepts.push(
// accept() for socket incoming[i] has resolved. Queue another so we keep
// accepting from the socket.
accepts.push(

streamer/src/quic.rs Show resolved Hide resolved
Copy link

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants