[email protected]
[Top] [All Lists]

[Haskell-cafe] Re: I/O performance drop in ghc 6.12.1

Subject: [Haskell-cafe] Re: I/O performance drop in ghc 6.12.1
From: Peter Simons
Date: Fri, 15 Jan 2010 00:05:10 +0100
Hi Svein,

 > Hold on, he's using hGetBuf/hPutBuf.

exactly, that's what I was thinking. When a program requests that 'n'
bytes ought to be read into memory at the location designated by the
given 'Ptr Word8', how could GHC possibly do any encoding or decoding?
That API doesn't allow for multi-byte characters. I would assume that
hGetBuf/hPutBuf are the equivalent to POSIX read() and write()?

 > I wonder if the difference goes away if the handle is explicitly set
 > to binary?

I added an

   mapM_ (\h -> hSetBinaryMode h True) [ stdin, stdout ]

to 'main', and it does seem to improve performance a little, but it's
still quite a bit slower than /bin/cat:

 | $ time /bin/cat <test.data  >/dev/null
 | real    0m2.119s
 | user    0m0.003s
 | sys     0m1.967s
 | $ time ./cat-hgetbuf <test.data  >/dev/null
 | real    0m3.449s
 | user    0m1.137s
 | sys     0m2.240s

Take care,

Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>