Skip to content

feat(udp): handle partial sendmsg_x progress#2748

Open
thomaseizinger wants to merge 1 commit into
mainfrom
feat/handle-partial-sendmsg-x-progress
Open

feat(udp): handle partial sendmsg_x progress#2748
thomaseizinger wants to merge 1 commit into
mainfrom
feat/handle-partial-sendmsg-x-progress

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This PR offers an alternative to #2672 that doesn't require buffering. For a detailed description, see the commit message.

@thomaseizinger

Copy link
Copy Markdown
Collaborator Author

cc @larseggert

@larseggert

Copy link
Copy Markdown
Contributor

I like it!

@thomaseizinger
thomaseizinger force-pushed the feat/handle-partial-sendmsg-x-progress branch from fce01a8 to aaaec9a Compare July 22, 2026 23:04
Comment thread quinn-udp/src/lib.rs Outdated
/// contents are empty.
pub fn datagram_count(&self) -> usize {
match self.segment_size {
Some(0) => panic!("segment size must be non-zero"),

@thomaseizinger thomaseizinger Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a bit of an annoying case.

Has it been discussed before to change segment size to a NonZeroUsize?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've removed this in favor of treating Some(0) like an unsegmented datagram.

Comment thread quinn-udp/src/unix.rs
// these by automatically clamping the MTUD upper bound to the interface MTU.
Err(e) if e.raw_os_error() == Some(libc::EMSGSIZE) => Ok(()),
Err(e) if e.raw_os_error() == Some(libc::EMSGSIZE) => {
Ok(SendCount::from_datagram_count(attempted_datagrams))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is also somewhat unfortunate. If it were after me, we should remove /deprecate the send functions.

The private `sendmsg_x` API that we use for batching sends on Apple has
roughly the same semantics as sendmmsg on Linux. Most importantly, it
can make partial progress and it will return the number of successfully
sent datagrams as a return value.

Right now, we are ignorning this return value, resulting in silent
packet drops under load. This has been confirmed in a LAN benchmark with
~ 2Gbit/s throughput.

`quinn-udp` doesn't integrate with any runtime and needs to offer an API
that makes sense across platforms. The new API tries to navigate both of
these constraints.

The public API remains largely unmodified except for the additions of
two items:

1. `UdpSocketState::send` now returns a `SendCount` that is
`#[must_use]`
2. `Transmit` exposes an `advance` function that consumes the
`SendCount`

Downstream users of `quinn-udp` will therefore receive a compiler
warning as soon as they upgrade to this new version. If ignored,
existing behaviour is preserved (i.e. packets get dropped).
@thomaseizinger
thomaseizinger force-pushed the feat/handle-partial-sendmsg-x-progress branch from aaaec9a to 25489df Compare July 23, 2026 00:33
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.

2 participants