-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
feat: Allow changing the UDP send/receive buffer sizes #2179
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long story short, I am in favor of this patch.
Increasing the UDP socket send and receive buffer can have a positive performance impact. That said, the additional memory footprint might not be an option for all quinn-udp
users. Thus an opt-in set of functions on UdpSocketState
seems ideal to me.
Long term, once we gathered more experience, we might want to bump the buffer sizes by default.
Worth having the code below use the new functions? Lines 28 to 49 in 434c358
|
Changes look good to me. CI is failing, e.g. on Windows with:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have played with this before as well and noticed some interesting behaviour on several platforms. Linux for example will give you however much buffer size it can if you request a really large size and not fail the function.
I am not sure if this is common knowledge around socket APIs :)
Maybe incorporating a log like the one pointed out by @mxinden would be worth it? Maybe not on warn
but on debug? Or we check and return our own error so users can log it themselves?
I am curious to learn about any performance gains you get from this. In my testing, this wasn't a bottleneck but that was also ~6 months ago and I've landed other perf improvements in our codebase since.
I am thinking that I will change the test to check that a "set" operation results in any change of the buffer size in the right direction (increase or decrease). |
I can't figure out why |
Do you know which of the syscalls in quinn/quinn-udp/src/windows.rs Lines 31 to 120 in 434c358
|
Seems to be |
Turns out one needs to bind both sockets on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget fallback.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Can you squash your changes into a single commit?
Do we want a quinn-udp version bump so this can be published?
@@ -86,6 +86,18 @@ impl UdpSocketState { | |||
1 | |||
} | |||
|
|||
/// Resize the send buffer of `socket` to `bytes`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: please remove the periods from the first sentences of docstrings.
))) | ||
.unwrap(); | ||
|
||
let sockstate = UdpSocketState::new(sock.into()).expect("created socket state"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: sockstate
-> sock_state
or even socket_state
.
I'll squash Monday. I also want to do a follow-up with methods for reading the buffer sizes. Bump afterwards would be nice. |
Just add a commit with a version bump when you're ready. |
Add
UdpSocketState::set_send_buffer_size
andUdpSocketState::set_recv_buffer_size
, which allow resizing the respective socket buffers.CC @mxinden