go-codec series: code generation to encode/decode json msgpack cbor; 2X-20X perf

54 views
Skip to first unread message

Ugorji Nwoke

unread,
Jan 8, 2015, 12:26:45 PM1/8/15
to golan...@googlegroups.com
Some folks asked me yesterday that it was not clear what code generation referred to with respect to go-codec, so I am posting the article focused on code generation capabilities. I would really appreciate your feedback of any kind, regarding what you like or dislike about it, the claims it makes, whether you find it useful, etc.


This is part on the go-codec series.

Summary:

go-codec supports compile-time generation of encoders and decoders for named types, which does not incur the overhead of reflection in the typical case, giving 2X-20X performance improvement over the idiomatic runtime introspection mode.

Idiomatic encoding and decoding types within go typically relies on the reflection capabilities of the go runtime. This affords flexible performance without the need for a pre-compilation step; the go types contain all the information needed and the runtime exposes the full types via reflection. However, introspecting the runtime to get this information has a noticeable overhead, which can be eliminated by a pre-compilation/code-generation step.

To eliminate that overhead, a pre-compilation step must be done to create the code which would have been inferred at runtime. This is why Protocol Buffers, Avro, etc have better performance than runtime-based systems. go-codec now provides the same capabilities, with the accompanying 2X-20X performance improvement depending on the size and structure of the named type.

More Discussion:

Reply all
Reply to author
Forward
0 new messages