Protobuf performance improvements #6068
-
@PeterJohnson I'm not sure whether this is the right place for this discussion, but I came across some of your performance numbers here and had a quick look at the ProtobufTranslation2d definition. Protobuf is unfortunately quite bad at encoding nested messages because of the additional size overhead and cost to pre-compute the header. Messages also can't be streamed in a single pass. ( message Translation2d {
double x = 1;
double y = 2;
}
message Translation2dList {
repeated Translation2d translations = 3;
} The above definition would encode an array of translations as a series of message Translation2dList {
repeated double x = 1 [packed=true];
repeated double y = 2 [packed=true];
} The flatter definition would be encoded as two flat double arrays and (on little endian systems) can be de-/serialized using a simple I don't know whether you can break backwards compatibility though. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Thanks for the suggestion! For the simple use cases like a simple array of fixed size structures, this is why we’ve developed Struct (basically C-style packed structures with a simple description language) as a higher speed and more byte efficient alternative to protobuf. While going to decomposed parallel arrays would be more storage efficient and decoding performant, it’s much less user-friendly for our dynamic use cases, where we want generic dashboards to be able to blow out data structures as the user would expect to see them. Your suggested approach might make sense to explore for the PhotonVision project, as they largely are using protobuf just for transport and not really intending it for interactive user inspection in the same way? @mcm001 @srimanachanta |
Beta Was this translation helpful? Give feedback.
Thanks for the suggestion! For the simple use cases like a simple array of fixed size structures, this is why we’ve developed Struct (basically C-style packed structures with a simple description language) as a higher speed and more byte efficient alternative to protobuf.
While going to decomposed parallel arrays would be more storage efficient and decoding performant, it’s much less user-friendly for our dynamic use cases, where we want generic dashboards to be able to blow out data structures as the user would expect to see them.
Your suggested approach might make sense to explore for the PhotonVision project, as they largely are using protobuf just for transport and not really intendin…