1.. _module-pw_protobuf-size_report: 2 3================================ 4pw_protobuf extended size report 5================================ 6pw_protobuf can impact binary size very differently depending on how it's used. 7A series of examples are provided below to illustrate how much certain use cases 8affect binary size. 9 10-------- 11Overview 12-------- 13This module includes a proto encoder, two different proto decoders (one that 14operates on a ``pw::stream::StreamReader`` and another that operates on an in- 15memory buffer), codegen for direct wire-format encoders/decoders, and a 16table-based codegen system for constructing proto messages as in-memory structs. 17 18Here's a brief overview of the different encoder/decoder costs: 19 20.. include:: size_report/protobuf_overview 21 22.. note:: 23 24 There's some overhead involved in ensuring all of the encoder/decoder 25 functionality is pulled in. Check the per-symbol breakdown for more details. 26 27-------------------------------- 28Encoder/decoder codegen overhead 29-------------------------------- 30The different proto serialization/deserialization codegen methods have different 31overhead. Some have a higher up-front cost, but lower complexity (and therefore 32smaller compiler generated code) at the sites of usage. Others trade lower 33up-front code size cost for more complexity at the proto construction and read 34sites. 35 36This example uses the following proto message to construct a variety of use 37cases to illustrate how code and memory requirements can change depending on 38the complexity of the proto message being encoded/decoded. 39 40.. literalinclude:: pw_protobuf_test_protos/size_report.proto 41 :language: protobuf 42 :lines: 14- 43 44This proto is configured with the following options file: 45 46.. literalinclude:: pw_protobuf_test_protos/size_report.options 47 :lines: 14- 48 49Trivial proto 50============= 51This is a size report for encoding/decoding the ``pw.protobuf.test.ItemInfo`` 52message. This is a pretty trivial message with just a few integers. 53 54.. include:: size_report/simple_codegen_size_comparison 55 56Optional and oneof 57================== 58This is a size report for encoding/decoding the 59``pw.protobuf.test.ResponseInfo`` message. This is slightly more complex message 60that has a few explicitly optional fields, a oneof, and a submessage. 61 62.. include:: size_report/oneof_codegen_size_comparison 63