[Haskell-beginners] Lazy file IO & Space leaks/waste

Nicolas Pouillard nicolas.pouillard at gmail.com
Fri Nov 6 04:25:22 EST 2009


Excerpts from Aleksandar Dimitrov's message of Thu Nov 05 12:01:11 +0100 2009:
> Hello list,
> 
> I'm currently writing a small linguistic corpus analyzer. My input file is only
> 25MB, but profiling shows that the overall amount of allocation over the
> program's runtime is several GB. That's a little too much - adding to that is
> the fact that the program is abysmally slow, so I'm suspecting a space leak
> somewhere.
> 
> I'm using the ByteString.Lazy.Char8 class in order to work efficiently with lazy
> IO and I must admit that I'm very inexperienced with predicting runtime and
> space behaviour of lazy IO :-( It worked well in the past, but I'm stuck now.
> 
> The program can be found here:
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11863#a11863

I've added a revision of your code and some highlights.
The main one is to suggest foldl' instead of foldr'. However without the input
text helping to improve is harder.

-- 
Nicolas Pouillard
http://nicolaspouillard.fr


More information about the Beginners mailing list