[Haskell-cafe] PSA: If you're serializing floating point numbers, don't use binary

Francesco Mazzoli f at mazzo.li
Tue Feb 9 10:19:35 UTC 2016


Serialization of floating point numbers with binary is fantastically slow and incorrect if you’re using NaNs, see

https://github.com/kolmodin/binary/issues/64 <https://github.com/kolmodin/binary/issues/64>
https://github.com/kolmodin/binary/issues/69 <https://github.com/kolmodin/binary/issues/69>
I recently spent half a day debugging performance problems because of this, and since backwards compatibility with older formats is required, this problem is probably not going to be solved.

We decided to switch to cereal for this reason. With some patches <https://github.com/GaloisInc/cereal/pull/46> cereal was 30x faster for the data we were serializing (scientific computing, mostly Doubles packed in nested records containing vectors).

The size of the serialized data is also roughly 3 times smaller – with binary a Double takes at least 25 bytes of space instead of 8. With Float it’s even worse, 25 bytes instead of 8.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160209/2019170b/attachment.html>


More information about the Haskell-Cafe mailing list