Is size of protobuf serialized data fixed for simple classes?

By simple classes i mean classes/structures that do not contain vectors, stacks, linked list or any other variable length data structures.

  1. If we have a class with some simple double, long, int,... fields, does serialized sizes of different instances of this class depend on the value of these fields? (e.g depending on number of meaningful bits, in case of ignoring left 0 bits to save space)

  2. How do strings affect size of serialized data?

Jon Skeet
people
quotationmark

You need to read the wire format documentation, basically.

The size of floating point fields will always be fixed, but for integers there are options: fixed32 and fixed64 will be fixed (as the name suggests), but int32, int64, sint32, sint64, uint32 and uint64 are variable-length, designed to make encoding of small values efficient.

Strings are encoded as the length of the UTF-8-encoded data, then the data itself. The length itself is serialized in a variable-length format, again so that short strings are encoded efficiently.

people

See more on this question at Stackoverflow