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

perf(udp): enable multi-message IO on apple #2279

Open
mxinden opened this issue Dec 10, 2024 · 0 comments · May be fixed by #2302
Open

perf(udp): enable multi-message IO on apple #2279

mxinden opened this issue Dec 10, 2024 · 0 comments · May be fixed by #2302

Comments

@mxinden
Copy link
Collaborator

mxinden commented Dec 10, 2024

We currently pass a single large read buffer to the OS across all platforms:

neqo/neqo-udp/src/lib.rs

Lines 66 to 70 in 3e65261

state.recv(
(&socket).into(),
&mut [IoSliceMut::new(recv_buf)],
slice::from_mut(&mut meta),
)?;

Linux, Android and Windows can leverage GRO (and URO) to read multiple datagrams into the buffer.

Apple platforms do not support GRO. But instead, we can fall-back to the older recvmmsg style syscalls.

@larseggert added recvmmsg style reads on apple to quinn-udp: quinn-rs/quinn#1993

In order to make use of this optimization on apple platforms, we should be passing multiple smaller read buffers to the apple OS, instead of one large buffer (see code above).

I suggest the following:

  1. Introduce a struct ReceiveBuffer(Vec<u8>) wrapper type with a new function using RECV_BUF_SIZE.
  2. Have the user pass a long-lived instance of ReceiveBuffer to recv_inner.
  3. Within recv_inner we can assert the size of receive_buffer.0, given that a user can construct it via new only. On Linux, Android, Windows, ... proceed as before, passing the single large buffer to the OS. On Apple, partition the buffer and pass multiple slices of it to the OS.
  4. On apple platforms, enable the fast_apple quinn-udp feature.

Alternatively on Apple platforms, we could change ReceiveBuffer(Vec<u8>) to ReceiveBuffer(Vec<Vec<u8>>).

Overarching tracking issue: #1693

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 a pull request may close this issue.

1 participant