[Haskell-cafe] sum-file shootout test

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Jun 1 04:37:30 EDT 2006


Hello Haskell-cafe,

i have analyzed performance of various sum-file implementations (see
http://shootout.alioth.debian.org/debian/benchmark.php?test=sumcol&lang=all )

first, one-liner implementation (attached as b.hs) works about 500
seconds on my cpu. it can be made 10x faster just by using it's own
'read' procedure (c.hs). this tells us that current 'read' implementation
in GHC is VERY SLOW.

next step to make things go faster you can see at
http://shootout.alioth.debian.org/debian/benchmark.php?test=sumcol&lang=ghc&id=4
- now it's the fastest GHC entry on this test. speedup is a result of
throwing away all the lines/map/read/sum individual procedures and
writing entire algorithm over the plain stream of Chars. this allows
us to omit all the construction/deconstruction of lazy boxes, so this
program works about 10 seconds on my box.

now the main problem is getContents itself, which uses about 70% of
total time, because it requires to construct/deconstruct lazy box for
each Char read. Using Streams library, we can omit this work and use
straightforward imperative code (h.hs). this program works 4 times
faster (2.8 seconds) than faster Haskell variant, what should be about
1.5 times faster than today's fastest (D Digital Mars) entry in this
test

i think that close speed can be also obtained by using line-oriented
I/O in Streams+ByteString combination and then applying some
"readInt :: ByteString -> Int" conversion while compiling under GHC 6.5


-- 
Best regards,
 Bulat                          mailto:Bulat.Ziganshin at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b.hs
Type: application/octet-stream
Size: 43 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060601/982a4193/b.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c.hs
Type: application/octet-stream
Size: 124 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060601/982a4193/c.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: h.hs
Type: application/octet-stream
Size: 614 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060601/982a4193/h.obj


More information about the Haskell-Cafe mailing list