Micromsg, BMessages
Created on 2020-08-31T02:20:03+00:00
For events which happen with extreme frequency (mouse motion, keyboard actions) a standard callback mechanism is used.
For events which happen at "control rate" message objects are used.
Messages associate a name and type code to a label or nameplate. Values are then chained in a list underneath a nameplate. It is allowable for the whole nameplate to have a fixed size for each value or for each value to have its own independent size.
Quinn's micromsg imposes a limit of 64k on the size of an entire message (including internal bookkeeping.) This was done because we use 16-bit integers in fields to conserve space and the Defold game engine hasn't had a problem with 64kb limits on messages. Also message broker systems (RabbitMQ, Beanstalkd, etc) recommend keeping only small payloads.
16-bit integers
A previous implementation used 32-bit integers and profiling found that over 60% of the space used in small messages was lost in overhead. Since small messages are the norm (large payloads are discouraged) this seemed to be extreme overhead (albeit one that faded out when around 5+ values were added.)