Is there a reason why all the fields for protobuf are declared as "optional", when it looks like they are in fact not optional at all?
Re:The Blink Protocol
by bchallenor on Sunday January 20, 2013 @05:36AM
(#5086502)
To support schema evolution. Of course it's up to you to write code that can actually handle missing fields, but once you have a required field in a message, you can never remove it.
From the docs:
"You should be very careful about marking fields as required. If at some point you wish to stop writing or sending a required field, it will be problematic to change the field to an optional field – old readers will consider messages without this field to be incomplete and may reject or drop them unintentionally. You should consider writing application-specific custom validation routines for your buffers instead. Some engineers at Google have come to the conclusion that using required does more harm than good; they prefer to use only optional and repeated. However, this view is not universal."
Re:The Blink Protocol
by randersson on Sunday January 20, 2013 @05:53AM
(#5086533)
good question; I usually declare fields optional for the reason described in the reply above. I just re-ran the test with all fields declared as "required". It ran ~2% faster.
http://blog.blinkprotocol.org/2013/01/blink-compared-to-goog...
As you can see in a comment by Rolf, part of the perf limitation of GPB is the implementation and not the wire protocol.
Anders