[Haskell-cafe] The state of binary (de)serialization

wren ng thornton wren at freegeek.org
Thu Feb 28 10:22:37 CET 2013


On 2/27/13 2:17 AM, Vincent Hanquez wrote:
> Two major problems of lazy bytestrings is that:
>
> * you can't pass it to a C bindings easily.
> * doing IO with it without rewriting the chunks, can sometimes (depending
>    how the lazy bytestring has been produced) result in a serious
degradation of
>    performance calling syscalls on arbitrary and small chunks (e.g.
socket's 'send').

If you're on a POSIX system, you can always make use of
unix-bytestring[1]. In particular, for lazy ByteStrings the function you
want is System.Posix.IO.ByteString.Lazy.fdWritev which performs a single
syscall to write all the chunks, and without manually concatenating them.

[1] http://hackage.haskell.org/package/unix-bytestring

-- 
Live well,
~wren




More information about the Haskell-Cafe mailing list