-
Notifications
You must be signed in to change notification settings - Fork 7
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
Re-visiting the serialization #214
Comments
In addition, there are places where a temporary buffer is created during the serialization, is it possible to apply a similar technique? Or even better, can these temporary buffers be removed since the reason why most of them are there in the first place was because the serialized format requires a size byte(s) prepended to the actual data. |
It might be better if this is introduced in a breaking update |
Initial experiment shows that this quite significantly degrades serialization performance for primitive types like |
Reserving capacity in buffer somehow negatively impact serializing |
This is interesting, I can't imagine why it would decrease the performance in this way. Just noting here that I'd expect the pre allocation to only improve performance as well. |
That was my expectation as well. I haven't got enough time to investigate further however. |
The current
to_vec()
method creates the output buffer withVec::new()
, and according to [1]This would inevitably get to re-allocation and probably repeated re-allocation if the object is large. However, given that we already have a
SizeSerializer
which can estimate the serialized size in bytes, this could potentially reduce the number of re-allocation.[1] https://nnethercote.github.io/perf-book/heap-allocations.html?highlight=borrow
The text was updated successfully, but these errors were encountered: