Should GHC default to -O1 ?

Daniel Fischer daniel.is.fischer at googlemail.com
Tue Nov 8 18:01:14 CET 2011


On Tuesday 08 November 2011, 17:16:27, Simon Marlow wrote:
> most people know about 1, but I think 2 is probably less well-known.
> When in the edit-compile-debug cycle it really helps to have -O off,
> because your compiles will be so much quicker due to both factors 1 & 2.

Of course. So defaulting to -O1 would mean one has to specify -O0 in the 
.cabal or Makefile resp. on the command line during development, which 
certainly is an inconvenience.

> 
> So the default -O setting is a careful compromise, trying to hit a good
> compile-time/runtime tradeoff.  Perhaps we're more sensitive in Haskell
> because -O can easily give you an order of magnitude or more speedup,

It can even make the difference between a smoothly running programme and a 
dying one, if one is naively using the right (wrong) constructs.

So the nub of the question is, which downside is worse?

My experience is limited, so I haven't sufficient data to form a reasoned 
opinion on that, hence I ask.

> whereas in C you're likely to get a pretty consistent 30% or so.  The
> difference between -O and -O2 is another careful tradeoff.
> 

> 
> I suppose we should really run an up to date set of benchmarks on some
> real Haskell programs (i.e. not nofib) and reconsider how we set these
> defaults.  I really doubt that we'll want to turn on -O by default,
> though.

I suppose there are no cheap but effective optimisations one could move to 
the default behaviour, or that would've been done :(




More information about the Glasgow-haskell-users mailing list