
On Wed, 2013-02-27 at 07:49 +0100, Vincent Hanquez wrote:
On Mon, Feb 25, 2013 at 01:30:40PM +0100, Nicolas Trangez wrote: ... I've been looking at the same thing lately, and i've been quite surprised, to say the least, by the usual go-to packages (cereal, binary). Performance wise this is hard to summarize, but if you serialize something small and have a easy to compute size (e.g. fixed size structure), i would advise against using any kind of builder structure (builder,cereal,binary), and go directly at the Storable level, if performance need to be on-par other languages.
My initial interpretation is that the builder initial cost is quite high, and only get amortized if the number of operations is quite high (and have less bytestrings). So if you have many structures encoded in one encoding operation it's probably ok-ish.
I've made the following benchmark when i was doing my experiments, that shows basic serialization of bytestring-y data structures:
* "bclass" is a simple function that use bytestring concat or append * "bclass+io" is a simple function that use mutable bytestring + poke to create the bytestring * "cereal" is cereal's encode function * "binary" is binary's encode function * "builder" is bytestring's builder.
* simple bytestring of constant size: <sz> * n bytestrings of same size: n*<sz> * n bytestrings of different size: <sz>+<sz2>+.. * n bytestrings plus a w32 prefixed size: len+n*<sz>
Obviously, caveat emptor:
http://tab.snarc.org/others/benchmark-bytestring-serialization.html
Let me know if anyone want the source file.
These are some really interesting (and very consistent) results, thanks! I guess I should do some benchmarking myself and maybe change some thing around (heck, now I'm using Builder to serialize constants :-P). It might be worth to share these benchmarks with the 'binary' and 'bytestring'/'blaze-builder' maintainers? Nicolas