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
bufio: use underlying ReadFrom even when data is buffered #44815
Comments
This seems like a completely reasonable optimization. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely accept. |
Change https://golang.org/cl/340530 mentions this issue: |
No change in consensus, so accepted. 🎉 |
Looks like it's done but not merged? @neild |
(*bufio.Writer).ReadFrom
will use the underlying writer'sReadFrom
method if present, but only when thebufio.Writer
has no data buffered.When the
http
package writes a request, it first writes the headers to abufio.Writer
and then usesio.Copy
to write the request body. The buffered headers prevent the use of the underlyingnet.Conn
'sReadFrom
. Flushing the headers before the body may result in an unnecessary additional write, and possibly split a small request across multiple packets.A similar problem may occur in other cases where a
bufio.Writer
has some amount of data written to it, followed by a large copy.ReadFrom
should instead fill out the current buffer, flush it, and then continue the operation with the underlying writer'sReadFrom
(when present).The text was updated successfully, but these errors were encountered: