-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature: Serve::tcp_nodelay
#2653
Conversation
Hi, this looks good to me. Can you just add an entry to the changelog please? |
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.
Is TCP_NODELAY
ever on by default, such that .tcp_nodelay(false)
would make sense to have? I was originally thinking that the method would be parameter-less.
axum/src/serve.rs
Outdated
|
||
/// Instructs the server to set the value of the `TCP_NODELAY` option on every accepted connection. | ||
/// | ||
/// See also [`TcpStream::set_nodelay`] |
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.
/// See also [`TcpStream::set_nodelay`] | |
/// See also [`TcpStream::set_nodelay`]. |
axum/src/serve.rs
Outdated
impl<M, S, F> WithGracefulShutdown<M, S, F> { | ||
/// Instructs the server to set the value of the `TCP_NODELAY` option on every accepted connection. | ||
/// | ||
/// See also [`TcpStream::set_nodelay`] |
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.
/// See also [`TcpStream::set_nodelay`] | |
/// See also [`TcpStream::set_nodelay`]. |
The idea was that there is maybe some configuration or OS where it could be enabled by default that I'm just not aware of. Just wanted to make sure that we don't mess with that default value and users can explicitly disable it. Again, I personally couldn't give you an example of such an OS or config. ("[..] On Mac OS there was no difference in performance between The comment doesn't imply that its not enabled tho. |
Hey, I'll try to get to this again soon. Your reasoning for having the bool parameter makes sense, let's keep that. |
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.
Looks good, could you rebase on top of / merge main? Should fix CI and merge conflicts.
Fixes: #2521
Motivation
See #2521 and linked issue in hyper
Solution
Adds the
tcp_nodelay
method toServe
(andWithGracefulShutdown
) to enable the user to instruct the server to setTCP_NODELAY
on incoming connections.Regarding tests: I wasn't really sure what you would like to have there (since
with_graceful_shutdown
also doesn't seem to have tests or I didn't find them, not sure), so pointers are appreciated.