Skip to content

fix: respecting max_datagrams in poll_transmit#2185

Merged
Ralith merged 2 commits into
quinn-rs:mainfrom
filipe-cantarelli:fix-max-datagrams-poll-transmit
Mar 28, 2025
Merged

fix: respecting max_datagrams in poll_transmit#2185
Ralith merged 2 commits into
quinn-rs:mainfrom
filipe-cantarelli:fix-max-datagrams-poll-transmit

Conversation

@filipe-cantarelli

@filipe-cantarelli filipe-cantarelli commented Mar 23, 2025

Copy link
Copy Markdown
Contributor

Hello,

I've been playing with quinn-proto recently and I noticed that, sometimes, when the maximum segment is large enough quinn will go over the max_datagrams limit of poll_transmit. I believe this PR will fix this issue.

Also, considering that quin-proto is a low level crate, it feels like this code:

let max_datagrams = match self.config.enable_segmentation_offload {
false => 1,
true => max_datagrams.min(MAX_TRANSMIT_SEGMENTS),
};

should be removed and left for the upper level code to decide what max limit they truly want to use.

@Ralith

Ralith commented Mar 23, 2025

Copy link
Copy Markdown
Collaborator

Also, considering that quin-proto is a low level crate, it feels like this code:

That code exists so that the application layer can easily opt out of GSO without needing to replace the UDP socket abstraction.

Comment thread quinn-proto/src/connection/mod.rs Outdated
Comment thread quinn-proto/src/connection/mod.rs Outdated
@filipe-cantarelli

Copy link
Copy Markdown
Contributor Author

Also, considering that quin-proto is a low level crate, it feels like this code:

That code exists so that the application layer can easily opt out of GSO without needing to replace the UDP socket abstraction.

How about max_datagrams.min(MAX_TRANSMIT_SEGMENTS), is it possible to remove this limitation so the app code request more than 10 segments?

@Ralith

Ralith commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Oh, you were concerned about the upper bound? We could probably get rid of that entirely, yeah.

@filipe-cantarelli filipe-cantarelli force-pushed the fix-max-datagrams-poll-transmit branch from d339e2c to aeffe92 Compare March 24, 2025 10:33
@filipe-cantarelli

Copy link
Copy Markdown
Contributor Author

Oh, you were concerned about the upper bound? We could probably get rid of that entirely, yeah.

Is this something that could be done here in this PR?

@Ralith

Ralith commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Is this something that could be done here in this PR?

Sure, in a separate commit.

@djc

djc commented Mar 24, 2025

Copy link
Copy Markdown
Member

(Be sure to rebase on main to appease CI.)

@filipe-cantarelli filipe-cantarelli force-pushed the fix-max-datagrams-poll-transmit branch from aeffe92 to 5900957 Compare March 24, 2025 16:26
@filipe-cantarelli

filipe-cantarelli commented Mar 24, 2025

Copy link
Copy Markdown
Contributor Author

Is this something that could be done here in this PR?

Sure, in a separate commit.

Should we keep the current quinn behavior by moving this max cap over there? From what I see, currently linux systems would start dumping 64 segments instead of 10. Maybe set a default of max 10 in there, but also expose a way to set accordingly?

@Ralith

Ralith commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Should we keep the current quinn behavior by moving this max cap over there?

That'd be safer than removing it outright, though bare quinn-proto users will still be affected. IMO we should consider relaxing it entirely, but if you're not interested in doing testing that (especially on Windows where the kernel-enforced limit is a full 512 datagrams) we could leave it to future work.

Maybe set a default of max 10 in there, but also expose a way to set accordingly?

We should avoid offering configuration knobs unless there's clear motivation to support multiple cases, i.e. evidence that no one value is adequate for the vast majority of users.

@filipe-cantarelli

Copy link
Copy Markdown
Contributor Author

Could I then move the 10 limit to quinn in this PR and then open an issue to follow up relaxing it? I could maybe work on that later.

As far as where to cap it, maybe here is a good place:
https://github.com/quinn-rs/quinn/blob/main/quinn/src/connection.rs#L984

@Ralith

Ralith commented Mar 24, 2025

Copy link
Copy Markdown
Collaborator

Could I then move the 10 limit to quinn in this PR and then open an issue to follow up relaxing it? I could maybe work on that later.

SGTM, thanks!

As far as where to cap it, maybe here is a good place:

Yep, that's the spot.

Comment thread quinn-proto/src/tests/mod.rs
@filipe-cantarelli

Copy link
Copy Markdown
Contributor Author

@Ralith Follow up issue created #2189

…tu is large enough to batch

When a TLP is the first in the batch and initial mtu is large enough to allow for batching it still should
stay under the max_datagrams limit
@filipe-cantarelli filipe-cantarelli force-pushed the fix-max-datagrams-poll-transmit branch from 5b6baab to d4a5dcf Compare March 26, 2025 14:47
@filipe-cantarelli

Copy link
Copy Markdown
Contributor Author

@djc, @Ralith what are the next steps for this pr?

@djc

djc commented Mar 27, 2025

Copy link
Copy Markdown
Member

Would be good to get another round of review from @Ralith before merging.

@flub flub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch. I remember looking at this and wondering that this was an odd way to check that condition, but didn't realise it would lead to this bug.

@Ralith Ralith left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@Ralith Ralith added this pull request to the merge queue Mar 28, 2025
Merged via the queue into quinn-rs:main with commit f8165c3 Mar 28, 2025
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.

4 participants