-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Zero-copy encoding and decoding #18
Comments
@00imvj00 Please take a look at vincentdephily@71627f9 I've spent some time trying to convert to
I'm currently leaning towards option 2, but would like some opinions. I'd also be ok with throwing that commit away and go with option 1. Note that one thing we need to do to get toward zero-copy is convert some |
For Zero-copy, instead of this, how about we keep references of offset? For example: If the overall packet length is 64 bytes, we store these bytes as byte-array internally and then for the password, instead of a string, we just store something like, from index to index, and build method get_password() -> &str, where we will return the reference. |
A I'm going to dogfood that in different contexts and see, but it's going to take a while. |
Yup, at this point we can experiment with couple of approaches and see which feels ergonomic. Again, the goal is to keep is simple and make it super performant. |
It might be possible to do some zero-copy encoding or decoding, especially of the publish payload.
Bytes
can do some refcounting behind the scene, so if we switch publish.payload from aVec<u8>
to aBytes
we should only have to create the slice, not its content.We should revise whether
encode()
anddecode()
should take animpl IntoBuf
andimpl IntoBufMut
rather than a straightBytesMut
.Last but not least, this all needs to be benchmarked.
The text was updated successfully, but these errors were encountered: