[Haskell-cafe] GHC predictability

David Roundy droundy at darcs.net
Fri May 9 17:38:11 EDT 2008


On Fri, May 09, 2008 at 02:24:12PM -0700, Don Stewart wrote:
> jeff.polakow:
> > Hello,
> > 
> > One frequent criticism of Haskell (and by extension GHC) is that it has
> > unpredictable performance and memory consumption. I personally do not find
> > this to be the case. I suspect that most programmer confusion is rooted in
> > shaky knowledge of lazy evaluation; and I have been able to fix, with
> > relative ease, the various performance problems I've run into. However I
> > am not doing any sort of performance critical computing (I care about
> > minutes or seconds, but not about milliseconds).
> > 
> > I would like to know what others think about this. Is GHC predictable? Is
> > a thorough knowledge of lazy evaluation good enough to write efficient
> > (whatever that means to you) code? Or is intimate knowledge of GHC's
> > innards necessary?
> > 
> > thanks,
> >   Jeff
> > 
> > PS I am conflating Haskell and GHC because I use GHC (with its extensions)
> > and it produces (to my knowledge) the fastest code.
> 
> This has been my experience to. I'm not even sure where
> "unpredicatiblity" would even come in, other than though not
> understanding the demand patterns of the code.

I think the unpredictability comes in due to the difficulty of predicting
resource useage in the presence of lazy data (and particularly lazy IO).
It's not really that hard to predict the behavior of code that you write,
but it can certainly be hard to predict the effect of changes that you make
to someone else's code.  It's an effect of the possibility of constructing
and consuming large data objects without ever holding them in memory.  It's
beautiful, and it's wonderful, but it's also really easy for someone to add
a second consumer of the same object, and send performance through the
floor.

Of course, one can avoid this particular pattern, but then you lose some of
the very nice abstractions that laziness gives us.
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Haskell-Cafe mailing list