fix(s2n-quic): make AsyncWrite::poll_flush a no-op#2347
Merged
Conversation
camshaft
marked this pull request as ready for review
October 9, 2024 17:51
Contributor
|
I guess you can't really document a trait impl, but do you think it would be worth updating the doc comments on the stream API to mention this behavior in the trait impls? |
camshaft
force-pushed
the
camshaft/flush-change
branch
from
October 9, 2024 21:21
8873e37 to
db11425
Compare
WesleyRosenblum
approved these changes
Oct 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
The current implementation of
tokio::io::AsyncWrite::poll_flushperforms a full flush of buffers, which means it waits for the peer to acknowledge all of the outstanding in the stream. However, this isn't the behavior most trait usage expects. Instead, it expectspoll_flushto flush any temporary buffers to the socket. You can see this expectation in theimpl AsyncWrite for TcpStream:https://github.com/tokio-rs/tokio/blob/679d7657dc267a4d6472597c91cdda8792cf9e97/tokio/src/net/tcp/stream.rs#L1358-L1359
An example of our current behavior going wrong is the tokio
framedutilities:https://github.com/tokio-rs/tokio/blob/679d7657dc267a4d6472597c91cdda8792cf9e97/tokio-util/src/codec/framed_impl.rs#L263
In this case, random calls to
poll_writewill result in a full flush of the stream, rather than pipelining the buffer. When comparing s2n-quic streams to something like TCP, we will be much worse.For the solution, I have made all of our
poll_flushtrait impls as no-ops to match TCP behavior. We preserve the associatedpoll_flushthat keeps the original behavior, in case applications are wanting to do that.Call-outs:
This is technically a behavior change. It's possible that an application is depending on this behavior to track when the stream was completely ACKed by the peer. But in reality, it's more likely that the application is expecting our trait impls to match what TCP does, which makes no guarantees. So I think the behavior change is preferred.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.