[zeromq-dev] Q: type-tagging messages - prefix an uint32 or a frame?

Michael Haberler mail17 at mah.priv.at
Mon Jun 29 12:54:00 CEST 2015


Hi Lionel,

> Am 29.06.2015 um 07:48 schrieb Lionel Orry <lionel.orry at gmail.com>:
> 
> Hi Michael,
> 
> Le 19 juin 2015 16:00, "Michael Haberler" <mail17 at mah.priv.at> a écrit :
> >
> > so far we are using protobuf for serialization, with a single protobuf message being the supertype and container of all possible other message contents
> >
> > we are switching to tagging - each frame has a 32bit-sized tag which encodes message type *), as well as message encoding
> >
> > so we have two options:
> >
> > (1) just prefix each message (whatever type/encoding) with the tag, in a single frame
> > (2) prepend a 4-byte frame with the tag, which says how to interpret the following frame
> >
> 
> You could also have a look at http://www.tnetstrings.org

back when we chose a serialisation stack I looked at netstrings as well and decided it is unsuitable for the purpose, as it provided no upside over protobufs but several disadvantages, like runtime parsing of fluffy ASCII (some of which might happen in-kernel); readability was a non-argument because the protobuf TextFormat is not only perfectly readable, but also a legit wire encoding

in the context of the problem at hand (tagging frames with a tuple of several values - type id and encoding etc in 32bits) I do not quite see what netstrings can help - the type tags would be variable-sized strings?

- Michael
> 
> >
> > (2) would be easier to autodetect for backwards compatibility, at the cost of extra ZMTP framing overhead
> > (1) would need a heuristic test which I dislike
> >
> > any suggestions one way or the other?
> > are there any significant runtime performance implications of using (2)?
> >
> > thanks,
> >
> > - Michael
> >
> >
> 
> Regards,
> Lionel
> 
> >
> >
> > *) since protobuf lacks a message type ID, Petteri Aimonen and me came up with the msgid option in the .proto spec, see https://github.com/nanopb/nanopb/search?utf8=%E2%9C%93&q=msgid
> > this could be useful for other protobuf users as message type ID's are a recurring question
> >
> >
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list