I am writing a 2D real-time RPG in C# and I am trying to implement client-server communication using protocol buffers. I am trying to figure out how to implement delta compression to reduce message sizes.
I have read the protobuf "optional" fields take up no extra space on the wire when they are not set (obviously they still do in local memory though), so if I can just programmatically determine my deltas efficiently I would be in better shape.
Here's the problem. I can think of a few ways, but none seem to be ideal. I was wondering if someone could point me in the right direction.
Try to keep a dirty bit array for EACH message-able class that gets cleared when a message is sent and marked when a variable changes. Then to send a message you just send the members that match the Boolean fields. This has LOW maintainability, but probably decent performance.
Every message-able class keeps a "pastMessage" member that gets updated saved when a message is sent. Then just serialize your current state and diff the two messages. This would probably have LOW performance and almost DOUBLE memory overhead for the game types..
Create a new message every time a message was sent and "fill-in-as-you-go." This would provide a better performance than the above, but still would essentially double my memory overhead on my server.
Any other ideas?