Cap'n Proto

From Just Solve the File Format Problem
Revision as of 06:26, 29 May 2019 by Effect2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
File Format
Name Cap'n Proto
Ontology
Extension(s) .capnp
Released 2013[1]

Cap'n Proto is a serialization format and RPC system meant to be an improved version of Protocol Buffers, written by the same author[2]. Its major claimed advantage over Protocol Buffers is fast serialization and very fast deserialization; parsing is done lazily and much more simply than in Protocol Buffers, mostly amounting to a small amount of bounds-checking. Compare Simple Binary Encoding and FlatBuffers in this regard.

Contents

Extensions

Cap'n Proto schema files have the extension ".capnp"[3]. It is not clear what, if any, extensions may be in use for the serialized format.

Segments

Cap'n Proto messages are generally divided into several units called "segments" in order to make construction of the message easier.[4] Messages using segments begin with a "segment table"[5] and then the content of those segments. It is possible to write a "flat" message that takes up a single segment, however, the help text of the CLI calls this "rare".

Packing

Cap'n Proto defines a very simple compression format called the "packing" format, which is essentially a variant of run-length encoding that only encode runs of bytes with value 0x00. This is especially useful because Cap'n Proto does not leave out zero-valued fields[6][7], and so without packing, messages may consist of long runs of zero bytes for the values of uninitialized fields. Packing can in many cases significantly reduce file size. See [1] for details on the format.

Canonical Form

"Canonicalized" messages are those belonging to a well-defined subset of the regular message format. Where packing is used on canonicalized messages, it is taken as a container rather than as part of the format (unlike for non-canonicalized messages). See [2] for a specification.

Software

  • Official library
    • Includes a CLI capable of dumping, converting, etc. messages
    • Debian packages capnproto, libcapnp-*
  • List at [3]

Links

References

  1. https://capnproto.org/news/2013-04-01-announcing-capn-proto.html
  2. https://capnproto.org/index.html, section "Why do you pick on Protocol Buffers so much?"
  3. https://capnproto.org/language.html
  4. https://capnproto.org/encoding.html#messages
  5. https://capnproto.org/encoding.html#serialization-over-a-stream; name is from https://capnproto.org/encoding.html#canonicalization
  6. https://capnproto.org/encoding.html#structs, and the fact that fast pointer access requires this to be true
  7. https://capnproto.org/news/2014-06-17-capnproto-flatbuffers-sbe.html
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox