Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was looking to Cap'n Proto's page and they say:

> Cap’n Proto gets a perfect score because there is no encoding/decoding step.

How do they achieve this?



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.


> 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.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: