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.
This brings us roughly back to where we were with
0.22.1
. The issue was excessive allocations.Prost supports zero-copy decoding for byte/string fields, but not for encoding. I had to resort to some unsafe code to remove an extra allocation during serialization to protobuf wire format, which I believe is justified due to the massive difference in maximum memory usage.
Benchmarks
These are very crude, and the variance is quite high. I chose the worst results out of 5 runs.
0.22.1
0.23.0
This branch
The most important metrics are wall clock time (how long it took for the program to exit), and max rss (the maximum amount of physical RAM the program used at any single point in time). I'm also including system time and page faults, both of which together provide a hint about how much the program is asking the OS to manage memory for it.
There may be a similar regression in decode perf, but I have not looked into that. It's unlikely to be as severe though. There are definitely improvements to be made there if we feel the need for them, such as decoding from
Bytes
which is specialized to zero-copy in prost.