Replies: 3 comments
-
|
I just want to add that prost supports bytes which is meant to provide zero-copy decoding for For example, running the prost benchmarks locally with `bytes` generation enabled |
Beta Was this translation helpful? Give feedback.
-
|
@brancz "zero copy" in the README is shorthand for the payload bytes of length-delimited fields are not copied from the input buffer into owned Rust types during decode. Varints, tags, and the fixed-width scalars are read, not copied in the memcpy sense. If that distinction would be clearer in the README we can tighten the wording — the claim we're making is narrower than "nothing is read from the input," and we don't want it to read as if it were. What a view does avoidA view is a borrow over the input buffer. For every length-delimited field, a view stores a slice into the original bytes:
The result is that What a view cannot avoidProtobuf's wire format is not a memory layout, so some re-encodings are inevitable:
The scan itself is eager (not lazy), because the per-field offset table is what makes subsequent field access O(1) without rescanning. A fully lazy design would push that cost onto the first field access instead, which is a different trade-off; buffa does not take it. Re: prost's Raw throughput (MiB/s, higher is better; Intel Xeon Platinum 8488C,
Observations:
So |
Beta Was this translation helpful? Give feedback.
-
|
I think this could be even clearer. It’s starting to make sense though, the point is that the input buffer never gets copied (hence zero copy), but it’s not zero-heap-allocations since the offset mask still needs to be computed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It’s unclear from the readme to what extend zero copy actually holds true. By my understanding, protobuf uses varints to encode any integers, which I would consider not to be zero-copy since we need to read up to 10bytes per integer in order to know offsets of other elements. It would be great if the readme explained that behavior and also when this resolution happens. Lazily when requesting to read certain parts? Eargerly (doesn’t seem zero copy either as the tree of messages would need to eagerly need to create a mask of offsets)?
Beta Was this translation helpful? Give feedback.
All reactions