-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
so it turns out that everything is always bytes
Currently, the `http_box::BoxBody` type erases both the type of the `http_body::Body` _and_ the `Body::Data` associated type (to `Box<dyn Buf + Send>`). However, it turns out that erasing the `Data` type isn't actually necessary: _all_ `Body` types in Linkerd use `Bytes` as the `Bytes` type. This branch changes `BoxBody` to just require that `B::Data` is `Bytes`, and always produce `Bytes` as its data type. This will enable a much more performant implementation of request body buffering for POST retries (linkerd/linkerd2#6130). Rather than copying all the bytes from a `dyn Buf` `Data` type into an additional buffer, we can just clone the `Bytes`, increasing the reference count for that buffer, and return the original `Bytes`. This means we don't need to perform additional memcpys to buffer bodies for retries; we just hold onto the already-allocated `Bytes` buffers. The cloned `Bytes` can then be stored in a vector, and if we have to write them out again for a retry, we can do one big vectored write :)
- Loading branch information
Showing
4 changed files
with
13 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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