<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">`cereal` and `bytestring` `Builder` work by encoding to a big-endian `Word64`. A bit more expensive than a blind `unsafeCoerce`, but same idea.</div><div class=""><br class=""></div><div class="">Francesco</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 9 Feb 2016, at 11:40, Tom Nielsen <<a href="mailto:tomn@beautifuldestinations.com" class="">tomn@beautifuldestinations.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I unsafeCoerce to Word64 first. This usually helps in making the output compatible with non-Haskell applications and is much faster.<div class=""><br class=""></div><div class="">Tom</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Feb 9, 2016 at 10:19 AM, Francesco Mazzoli <span dir="ltr" class=""><<a href="mailto:f@mazzo.li" target="_blank" class="">f@mazzo.li</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><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" class="">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" class="">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" class="">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)" class=""><li style="margin:0px" class=""><a href="https://github.com/kolmodin/binary/issues/64" style="color:rgb(65,131,196);margin-top:0px" target="_blank" class="">https://github.com/kolmodin/binary/issues/64</a></li><li style="margin:0px" class=""><a href="https://github.com/kolmodin/binary/issues/69" style="color:rgb(65,131,196);margin-top:0px" target="_blank" class="">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)" class="">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)" class="">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" class="">cereal</code> for this reason. With <a href="https://github.com/GaloisInc/cereal/pull/46" style="color:rgb(65,131,196)" target="_blank" class="">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" class="">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" class="">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" class="">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" class="">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" class="">Float</code> it’s even worse, 25 bytes instead of 8.</p></div><br class="">_______________________________________________<br class="">
Haskell-Cafe mailing list<br class="">
<a href="mailto:Haskell-Cafe@haskell.org" class="">Haskell-Cafe@haskell.org</a><br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px" class=""><font face="Times" size="4" class=""><b class="">Tom Nielsen | Chief Data Science Officer </b> </font></div><div dir="ltr" class=""><font face="Times" color="#666666" size="2" style="color:rgb(136,136,136);font-size:12.8px" class="">Soho works | Tea building | </font><font color="#666666" face="Times" size="2" class="">56 Shoreditch High St | London E1 6JJ</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px" class=""><font face="Times" color="#666666" size="2" class="">+44 7961 270 416</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px" class=""><font face="Times" size="2" class=""><br class=""></font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px" class=""><font face="Times" size="2" class=""><b class="">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" class=""><font face="Times" color="#666666" size="2" class=""><a href="https://instagram.com/beautifuldestinations/" style="color:rgb(17,85,204)" target="_blank" class="">Destinations</a> | <a href="https://instagram.com/beautifulhotels" style="color:rgb(17,85,204)" target="_blank" class="">Hotels</a> | <a href="https://instagram.com/beautifulcuisines" style="color:rgb(17,85,204)" target="_blank" class="">Cuisines</a> | <a href="https://instagram.com/beautifulmatters" style="color:rgb(17,85,204)" target="_blank" class="">Matters</a></font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px" class=""><font face="Times" color="#666666" size="2" class=""><a href="http://www.beautifuldestinations.com/" style="color:rgb(17,85,204)" target="_blank" class="">www.beautifuldestinations.com</a></font></div></div></div></div></div>
</div>
</div></blockquote></div><br class=""></div></body></html>