Shared memory

106 views
Skip to first unread message

Mario Not64

unread,
Oct 22, 2020, 11:55:58 PM10/22/20
to Protocol Buffers
Hello,

New to protobuf.  Like to implement it in our existing code base. We currently use cereal to serialiaze the data.  We have over 100 structs/classes send over TCP/IP.  However reading about protobuf I came across an issue that I wounder if other have tackled and found a solution for.

My understanding of protobuf is you defined your objects in .proto files, protobuf generates .h and .cc files (c++ in our case)  creating matching classes.  However most of are structs need to be POD (plain old data) because they also live in shared memory.  That seems totally incompatible with protobuf. That tells me when such struct need to be protobuffed , they must be copied into a protobuf version of that struct. That sounds like a high maintenancy, high risk proposition.

Suggestion ?

Regards,
Mario

Adam Cozzette

unread,
Oct 23, 2020, 12:03:10 PM10/23/20
to Mario Not64, Protocol Buffers
You are right that C++ protos are not POD and therefore might not be a good fit for your use case. You could try looking at other protobuf implementations such as UPB and protobuf-c. Since they are written in C I think they meet the POD requirement.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/de357190-edbb-442b-a952-39cec6a51814n%40googlegroups.com.

Mario Not64

unread,
Oct 28, 2020, 2:29:14 PM10/28/20
to Protocol Buffers
Thanks for the feedback.

Would it make sense for protobuf to create a class as per the .proto definition but with NO extra stuff, in its own .h file.   Then the real  message proto class would derive from that.  Any code that used the class only need to include the .h of the class no need to drag all the protobuf stuff with it.  The message class would provide copy fonctions to easely transfer data from and to the real and message class. ?

Adam Cozzette

unread,
Oct 28, 2020, 5:38:29 PM10/28/20
to Mario Not64, Protocol Buffers
That could work but I suspect it would be a fair amount of work to implement. I think at that point you would almost be implementing an alternative serialization format for protocol buffers. Would it make sense to just store the plain binary format in shared memory?

Mario Not64

unread,
Nov 19, 2020, 4:22:36 PM11/19/20
to Protocol Buffers
By binary format, you mean the serialized data.  In our scenario, shared memory is not used as a transport medium, it's the data itself.  Think of it as variables not shared between threads but between processes.  
Reply all
Reply to author
Forward
0 new messages