feat(udp): handle partial sendmsg_x progress#2748
Open
thomaseizinger wants to merge 1 commit into
Open
Conversation
thomaseizinger
marked this pull request as ready for review
July 22, 2026 06:29
thomaseizinger
requested review from
Ralith,
djc,
gretchenfrage and
mxinden
as code owners
July 22, 2026 06:29
Collaborator
Author
|
cc @larseggert |
thomaseizinger
force-pushed
the
feat/handle-partial-sendmsg-x-progress
branch
from
July 22, 2026 06:29
837f441 to
fce01a8
Compare
Contributor
|
I like it! |
thomaseizinger
force-pushed
the
feat/handle-partial-sendmsg-x-progress
branch
from
July 22, 2026 23:04
fce01a8 to
aaaec9a
Compare
thomaseizinger
commented
Jul 22, 2026
| /// contents are empty. | ||
| pub fn datagram_count(&self) -> usize { | ||
| match self.segment_size { | ||
| Some(0) => panic!("segment size must be non-zero"), |
Collaborator
Author
There was a problem hiding this comment.
This is a bit of an annoying case.
Has it been discussed before to change segment size to a NonZeroUsize?
Collaborator
Author
There was a problem hiding this comment.
I've removed this in favor of treating Some(0) like an unsegmented datagram.
thomaseizinger
commented
Jul 22, 2026
| // 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)) |
Collaborator
Author
There was a problem hiding this comment.
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
force-pushed
the
feat/handle-partial-sendmsg-x-progress
branch
from
July 23, 2026 00:33
aaaec9a to
25489df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR offers an alternative to #2672 that doesn't require buffering. For a detailed description, see the commit message.