๐Ÿ“Protobuf: wrapping fields into embedded messages might decrease their size

Because field numbers 1โ€“15 take 1 byte to encode, if a Message has many fields past 15 which are present most of the time, it might be advantageous to wrap them into embedded message.

Embedded messages adds 2โ€“4 bytes of overhead (1โ€“2 bytes for field number + 1โ€“2 bytes message size), but saves 1 bytes for each nested field.

Backlinks