<div dir="ltr">I unsafeCoerce to Word64 first. This usually helps in making the output compatible with non-Haskell applications and is much faster.<div><br></div><div>Tom</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 9, 2016 at 10:19 AM, Francesco Mazzoli <span dir="ltr"><<a href="mailto:f@mazzo.li" target="_blank">f@mazzo.li</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><p style="margin-right:0px;margin-bottom:15px;margin-left:0px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255);margin-top:0px!important">Serialization of floating point numbers with <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">binary</code> is fantastically slow and incorrect if you’re using <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">NaN</code>s, see</p><ul style="margin:15px 0px;padding-left:30px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)"><li style="margin:0px"><a href="https://github.com/kolmodin/binary/issues/64" style="color:rgb(65,131,196);margin-top:0px" target="_blank">https://github.com/kolmodin/binary/issues/64</a></li><li style="margin:0px"><a href="https://github.com/kolmodin/binary/issues/69" style="color:rgb(65,131,196);margin-top:0px" target="_blank">https://github.com/kolmodin/binary/issues/69</a></li></ul><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)">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.</p><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)">We decided to switch to <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">cereal</code> for this reason. With <a href="https://github.com/GaloisInc/cereal/pull/46" style="color:rgb(65,131,196)" target="_blank">some patches</a> cereal was 30x faster for the data we were serializing (scientific computing, mostly <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Double</code>s packed in nested records containing vectors).</p><p style="margin-top:15px;margin-right:0px;margin-left:0px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255);margin-bottom:0px!important">The size of the serialized data is also roughly 3 times smaller – with <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">binary</code> a <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Double</code> takes at least 25 bytes of space instead of 8. With <code style="margin:0px 2px;padding:0px 5px;white-space:nowrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Float</code> it’s even worse, 25 bytes instead of 8.</p></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font color="#000000" face="Times" size="4"><b>Tom Nielsen | Chief Data Science Officer </b> </font></div><div dir="ltr"><font face="Times" color="#666666" size="2" style="color:rgb(136,136,136);font-size:12.8px">Soho works | Tea building | </font><font color="#666666" face="Times" size="2">56 Shoreditch High St | London E1 6JJ</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font face="Times" color="#666666" size="2">+44 7961 270 416</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font color="#000000" face="Times" size="2"><br></font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font color="#000000" face="Times" size="2"><b>Beautiful Destinations | The world’s largest travel influencer on Instagram</b></font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font face="Times" color="#666666" size="2"><a href="https://instagram.com/beautifuldestinations/" style="color:rgb(17,85,204)" target="_blank">Destinations</a> | <a href="https://instagram.com/beautifulhotels" style="color:rgb(17,85,204)" target="_blank">Hotels</a> | <a href="https://instagram.com/beautifulcuisines" style="color:rgb(17,85,204)" target="_blank">Cuisines</a> | <a href="https://instagram.com/beautifulmatters" style="color:rgb(17,85,204)" target="_blank">Matters</a></font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font face="Times" color="#666666" size="2"><a href="http://www.beautifuldestinations.com/" style="color:rgb(17,85,204)" target="_blank">www.beautifuldestinations.com</a></font></div></div></div></div></div>
</div>