News for hackers. Stuff that matters.
Re:The ups of downs of porting 50k lines of C++ to Go by stingraycharles on Saturday March 07, 2015 @06:43AM (#9161620)
Protocol buffers allows you to reuse the memory of your objects. You can simply reuse the object where you parse your message into. You pool these objects, and you just saved yourself a huge amount of heap allocations.

https://developers.google.com/protocol-buffers/docs/referenc...

Re:The ups of downs of porting 50k lines of C++ to Go by logicchains on Saturday March 07, 2015 @06:58AM (#9161643)
This would work if we were only using them for messaging, but the protobuffer objects are also used as the datastructure in which the information they contain is stored. This was done in the name of simplicity, to avoid creating a separate internal datastructure for each kind of message.

The flow of data is currently:

various external sources -> merged into protocol buffer struct -> later sent to client

To avoid keeping a heap of protocol buffer structs in the heap, this would need to change to:

various external sources -> merged into some internal datastructure -> later converted into protocol buffer struct and sent to client.

Re:The ups of downs of porting 50k lines of C++ to Go by scottlamb on Monday March 09, 2015 @08:24PM (#9175090)
> This would work if we were only using them for messaging, but the protobuffer objects are also used as the datastructure in which the information they contain is stored. This was done in the name of simplicity, to avoid creating a separate internal datastructure for each kind of message.

Did you consider keeping strings (serialized messages) in your cache rather than message objects? I do this in C++ code simply for memory efficiency. Here it would also allow you to avoid these extra pointers.