Simon Peyton-Jones wrote:
| There may well have been changes to the strictness analyser that make
| some of the bangs (or most) unnecessary now. Also, its very likely
| I didn't check all combinations of strict and lazy arguments for the
| optimal evaluation strategy :)
|
| If it seems to be running consitently faster (and producing better Core
| code), by all means submit. I don't think this is a ghc bug or anything
| like that though: just overuse of bangs, leading to unnecessary work.
You might think that unnecessary bangs shouldn't lead to unnecessary work -- if
GHC knows it's strict *and* you bang the argument, it should still only be
evaluated once. But it can happen. Consider
f !xs = length xs
Even though 'length' will evaluate its argument, f nevertheless evaluates it too. Bangs
say "evaluate it now", like seq, because we may be trying to control space
usage. In this particular case it's silly, because the *first* thing length does is
evaluate its argument, but that's not true of every strict function.
That's why I say it'd be good to have well-characterised examples. It *may* be
something like what I describe. Or it may be a silly omission somewhere.
A little addition to what Simon mentioned above: while it is definitely
true that adding unnecessary bangs can cause a slowdown, the slowdown
should be much less with 6.8.1 because in the common case each evaluation
will be an inline test rather than an out-of-line indirect jump and return.
So, with 6.8.x, you should feel more free to sprinkle those bangs...
Cheers,
Simon
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe