Skip to content

fix(apple): buffer unsent tail of partial sendmsg_x calls#2672

Draft
thomaseizinger wants to merge 2 commits into
quinn-rs:mainfrom
thomaseizinger:claude/practical-maxwell-3GjgP
Draft

fix(apple): buffer unsent tail of partial sendmsg_x calls#2672
thomaseizinger wants to merge 2 commits into
quinn-rs:mainfrom
thomaseizinger:claude/practical-maxwell-3GjgP

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Seeking some early feedback on this. Whilst debugging some performance problems, @jamilbk discovered that we are discarding the return value of sendmsg_x and may thus be silently dropping datagrams if e.g. only 4 out of 32 packets were sent.

In order to retain the current API, I opted for exploring a buffering approach. In case of a partial send, we buffer the remaining tail of the batch and return Ok(()). This will trigger the caller to pass us another Transmit at which point we will first try to flush the buffered tail before continuing on to the next batch.

An alternative would be to surface the partial send to the caller but that would leak into all other platforms.

Comment thread quinn-udp/tests/tests.rs

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.

Disclaimer: Claude wrote this one, I haven't verified it yet.

@thomaseizinger thomaseizinger force-pushed the claude/practical-maxwell-3GjgP branch from 4357a97 to 45be9f7 Compare June 7, 2026 16:36
@thomaseizinger thomaseizinger force-pushed the claude/practical-maxwell-3GjgP branch from 45be9f7 to 9729227 Compare June 7, 2026 17:05
@mxinden

mxinden commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

//CC @larseggert

@larseggert

Copy link
Copy Markdown
Contributor

For a bulk transfer, can this get us into a state where we're just pushing a remainder from transmit to transmit, causing memcpy churn? (We have a partial transmit, save a remainder, on next send try to send the remainder and the actual transmit, can't, and end up with another remainder?)

@thomaseizinger

Copy link
Copy Markdown
Collaborator Author

For a bulk transfer, can this get us into a state where we're just pushing a remainder from transmit to transmit, causing memcpy churn? (We have a partial transmit, save a remainder, on next send try to send the remainder and the actual transmit, can't, and end up with another remainder?)

In theory yes. I think that is still better than pretending to have sent the packets when instead they have been dropped. We'd have to gather some field-data to see how often that happens or we build in an algorithm that dynamically tunes the batch size?

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.

3 participants