3 ms·
It’s an untruth. There is a validation step of course, which means that there is a decoding step. There is no encoding step because the wire format is the same
by zarzavat 4y ago
It’s an untruth. There is a validation step of course, which means that there is a decoding step. There is no encoding step because the wire format is the same as the in-memory representation.
- kentonv 4y ago> There is a validation step of course No, there isn't. Not any more than there is a decode step anyway. The truth is that encoding, decoding, and validation all occur when you call the accessor methods for specific fields. If you never actually call the getter for some field, it won't be decoded nor validated at all. If you are going to be reading the entire message tree, then zero-copy is only an incremental improvement on something like Protobuf -- the use of fixed-width values may make decoding faster (or slower, in some cases). The real magic is when you want to read just one field of a 10GB file. Just mmap() the whole thing and treat it like a byte array, and it'll be efficient. Cap'n Proto will not attempt to scan the whole file, only the parts that you explicitly query. (I'm the author of Cap'n Proto.)