-
Notifications
You must be signed in to change notification settings - Fork 10
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: turn off Nagle's algorithm #41
Conversation
src/net/mod.rs
Outdated
Ok(_) => Ok(Stream { | ||
inner: StreamImpl::Tcp(s), | ||
}), | ||
Err(x) => Err(x), |
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.
If we do decide that erroring out is the best option, can change this to a s.set_nodelay(true)?
, but this is easier until we figure out semantics.
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.
Best-effort is probably fine, with debug logging before returning.
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.
Ack, that's probably the best option.
Nagle's algorithm prevents transmission of small packets as long as there are outstanding unacknowledged packets, instead buffering data locally. When combined with delayed acknowledgements, this can lead to poor latency with both ends of the connection waiting for each other. Turn off Nagle's algorithm by default to improve latency.
let res = s.set_nodelay(true); | ||
if res.is_err() { | ||
eprintln!("Error setting TCP_NODELAY: {:?}", res.err()); | ||
} |
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 realize this is already merged but in the future it would be cleaner to do
if let Err(e) = s.set_nodelay(true) {
eprintln!("Error setting TCP_NODELAY: {e:?}");
}
Nagle's algorithm prevents transmission of small packets as long as
there are outstanding unacknowledged packets, instead buffering data
locally. When combined with delayed acknowledgements, this can lead
to poor latency with both ends of the connection waiting for each other.
Turn off Nagle's algorithm by default to improve latency.