Haskell performance
Simon Marlow
simonmar at microsoft.com
Thu Mar 18 14:55:01 EST 2004
> Okay. What's really bothering me is that I can't find any good
> indication of what to do to get IO faster. Do I need to FFI the whole
> thing and have a C library give me large chunks? Or can I get by with
> hGet/PutArray? If so, what sizes should they be? Should I use memory
> mapped files?
hGet/PutArray should be pretty quick. For small requests, they get the
usual buffering treatment that other Handle operations have, and for
large requests the buffer is bypassed. For reading a file in one go,
hGetArray (or hGetBuf) is the way to go.
GHC itself uses hGetBuf for reading source files, hGetArray for reading
interface files, and hPutBuf for writing output.
Memory mapped files (mmap) should be even quicker. But then you'll have
to use peek & co from Foreign to access the bytes.
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list