Golang Serialization Benchmark 2020 Edition

  • Bebop codegen from .bop (need to create schema like protobuf)
  • Gencode codegen from .schema (similar to go syntax)
  • XDR2 codegen version (other libs are using reflection/automatic), unmaintained
  • Mum manual (must create the method to serialize and deserialize yourself), new name is enkodo
  • Colfer codegen from .colf (similar to go syntax)
  • Gogoprotobuf codegen from .proto
  • Gotiny codegen, not recommended for production
  • MsgPack codegen version (other libs are using reflection/automatic), from .go source file using go:generate, supported in lots of language
  • FlatBuffers codegen, can be used in gRPC
  • codegen means there are step to generate golang function by writing a schema definition file then run a program to convert that file to specific programming language implementation, sometimes using other format (so you cannot add custom tag to generated .go file), sometimes using golang struct with tag (like codegen version of msgpack above you need to label each property with , so you can add your own custom tag on the struct property, eg. `json:”bar,omitempty” form:”baz” bson:”blabla”` )
  • manual means you must write the serialization and deserialization yourself for each property of the struct (the library only the helper), this allows highly flexible system, so for example you read 1 byte first, then if the value is 1 then you read a string, if 2 you read int32, and so on. This can also be useful to parse network packet if having the same endian.
  • automatic means you don’t need to write any schema, it uses reflection so should be slower than codegen version.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store