feat(codec): revert to tokio-util
traits
#773
Closed
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.
Motivation
See the discussion post I made a couple of weeks ago.
Pull request #208 introduced
tonic::codec::{DecodeBuf, Decoder, EncodeBuf, Encoder}
in preparation for experimenting with a different decoding strategy, but as it currently stands the in-tree functionality is equivalent to the original implementation usingtokio_util::codec::{Decoder, Encoder}
andbytes::BytesMut
.Solution
Given that a significant amount of time has passed with no experimentation having happened (as far as I can tell), this commit reverts those changes. Additionally, it also restores efficient use of the underlying buffers, an issue that was brought up later in its respective comment thread.
Benchmarks
The performance impact is negligible, but still worth noting. I ran this on my 2020 13-inch M1 MacBook Pro (16GB RAM), if that matters.
Before:
After:
(I ran
cargo bench 2>&1 | grep bench:
to produce these figures, my apologies if I am missing anything)