Open
Description
The default write strategy for HTTP/1 in hyper is to automatically to chose the "best" option. Currently, it simply determines the best based on if AsyncWrite::is_write_vectored()
. However, depending on if the response bodies are usually big or usually small, flatten or queue might be better.
The suggested improvement here is:
- Determine a best-guess size for when bodies smaller than N should prefer
Flatten
. Make it a constant and document how the number was determined. - In
proto/h1/io.rs
:- Add an
Auto
variant toWriteStrategy
, and default to it. If the user has specified a strategy, the default will be overridden already.- If the underlying IO doesn't support vectored writes, set the strategy to
Flatten
.
- If the underlying IO doesn't support vectored writes, set the strategy to
- In
WriteBuf::buffer()
, if the strategy isAuto
, check if the buffer size is less than the defined constant. If it is smaller, then change the strategy toFlatten
, otherwise change it toQueue
.
- Add an
There's no need for any public API changes.