-O vs. -O2

Roman Leshchinskiy rl at cse.unsw.edu.au
Wed May 5 07:24:53 EDT 2010


Whenever I do cabal sdist on one of my projects, I get this warning:

Distribution quality warnings:
'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit
and not just imposing longer compile times on your users.

This finally got me curious and I did a nofib run to compare -O to -O2. The results are below (this is with the current HEAD).

Is there a real-world example of -O2 causing significantly longer compile times without providing a real benefit? If not, would it perhaps make sense for Cabal to use -O2 by default or even for GHC to make the two flags equivalent?

Roman

NoFib Results

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed
--------------------------------------------------------------------------------
           anna          +2.5%     -0.2%      0.08      0.11
           ansi          +0.0%     +0.0%      0.00      0.01
           atom          +0.0%     +0.0%      0.20     +0.0%
         awards          +0.0%     +0.0%      0.00      0.01
         banner          +0.0%     +0.0%      0.00      0.01
     bernouilli          +0.0%     +0.0%     +0.0%     +0.5%
          boyer          +0.0%     -0.3%      0.03      0.04
         boyer2          +0.2%     +0.0%      0.00      0.01
           bspt          +0.4%     +0.0%      0.00      0.02
      cacheprof          +0.6%     +0.0%     +0.0%     +0.0%
       calendar          +0.2%     +0.1%      0.00      0.01
       cichelli          +0.0%     -0.0%      0.07      0.08
        circsim          +0.2%     -0.0%     -1.4%     +0.3%
       clausify          +0.2%     -6.8%      0.03      0.04
  comp_lab_zift          +0.8%     +0.7%      0.17      0.19
       compress          +0.0%     +0.0%      0.14      0.16
      compress2          +2.3%     -1.3%      0.14      0.17
    constraints          +0.0%     +0.0%     -0.4%     -0.0%
   cryptarithm1          +0.0%     +0.0%     +0.0%     -0.3%
   cryptarithm2          +0.0%     -4.7%      0.01      0.02
            cse          +0.0%     +0.0%      0.00      0.01
          eliza          +0.0%     +0.0%      0.00      0.01
          event          +0.2%     +1.5%      0.14      0.16
         exp3_8          +0.0%     +0.0%      0.10      0.11
         expert          +0.4%     +0.4%      0.00      0.01
            fem          +0.5%     +1.0%      0.02      0.02
            fft          +0.2%     -1.6%      0.03      0.04
           fft2          +0.2%     +0.0%      0.06      0.07
       fibheaps          +0.2%     +0.4%      0.03      0.04
           fish          +0.0%     +0.0%      0.01      0.03
          fluid          +2.1%     -1.9%      0.01      0.02
         fulsom          +0.2%     +0.0%     +0.0%     -0.5%
         gamteb          +0.7%     -2.1%      0.07      0.09
            gcd          +0.0%     -1.7%      0.02      0.02
    gen_regexps          +0.0%     +0.0%      0.00      0.01
         genfft          +0.0%     -0.3%      0.03      0.03
             gg          +0.5%     -0.8%      0.01      0.02
           grep          +0.2%     +0.0%      0.00      0.01
         hidden          +0.3%     +0.0%     -3.2%     -3.5%
            hpg          +0.2%     +0.0%      0.14     +0.6%
            ida          +0.5%     -0.7%      0.07      0.08
          infer          +0.0%     +0.0%      0.04      0.05
        integer          +0.0%     +0.0%     +0.0%     +0.0%
      integrate          +0.0%     +0.0%     +0.0%     +0.0%
        knights          +0.7%    -13.4%      0.00      0.01
           lcss          +0.0%     -0.0%     -0.8%     -0.7%
           life          +0.0%     +0.0%      0.20     -1.0%
           lift          +0.2%     +3.6%      0.00      0.01
      listcompr          +0.0%     +0.0%      0.09      0.12
       listcopy          +0.0%     -0.0%      0.10      0.13
       maillist          +0.0%     -0.2%      0.05     +0.2%
         mandel          +0.0%     +0.0%      0.07      0.09
        mandel2          +0.2%    -67.2%      0.00      0.00
        minimax          +0.0%     +0.4%      0.00      0.01
        mkhprog          +0.0%     +0.0%      0.00      0.01
     multiplier          +0.0%     +0.0%      0.09      0.11
       nucleic2          +0.0%     +0.0%      0.06      0.07
           para          +0.9%     +0.5%     +6.4%     +5.5%
      paraffins          +0.4%     +0.2%      0.07      0.10
         parser          +0.5%     +0.3%      0.03      0.04
        parstof          +0.2%     -2.5%      0.00      0.01
            pic          +0.4%     -0.8%      0.00      0.02
          power          +0.4%     +0.0%     +0.0%     +0.8%
         pretty          +0.2%     -2.9%      0.00      0.01
         primes          +0.0%     +0.0%      0.05      0.06
      primetest          +0.2%     +0.0%     +0.0%     +0.6%
         prolog          +0.2%     -0.9%      0.00      0.01
         puzzle          +0.0%     +0.0%      0.14      0.16
         queens          +0.0%    -72.0%      0.01      0.02
        reptile          +0.2%     +0.0%      0.01      0.02
        rewrite          +0.2%     +0.0%      0.01      0.02
           rfib          +0.0%     +0.0%      0.04      0.05
            rsa          +0.0%     +0.0%      0.06      0.07
            scc          +0.0%     +0.0%      0.00      0.01
          sched          +0.2%     +0.6%      0.02      0.03
            scs          +0.8%     -0.4%     +0.0%     +1.4%
         simple          +0.2%     +0.0%     +0.0%     +0.0%
          solid          +0.0%     -0.0%      0.11      0.13
        sorting          +0.2%     +0.0%      0.00      0.01
         sphere          +0.0%     +0.5%      0.08      0.09
         symalg          +0.5%     -0.0%      0.03      0.04
            tak          +0.0%     +0.0%      0.01      0.02
      transform          +0.6%     -0.0%     +0.0%     +0.7%
       treejoin          +0.2%     -2.0%      0.20     +3.5%
      typecheck          +0.0%     +0.3%      0.19     +0.0%
        veritas          +1.0%     -0.3%      0.00      0.01
           wang          +0.0%     -1.0%      0.07      0.09
      wave4main          +0.0%     +0.0%     +3.7%     +1.4%
   wheel-sieve1          +0.2%     +0.0%     +0.0%     -0.8%
   wheel-sieve2          +0.2%     +0.0%      0.14      0.17
           x2n1          +0.0%     -1.3%      0.02      0.03
--------------------------------------------------------------------------------
            Min          +0.0%    -72.0%     -3.2%     -3.5%
            Max          +2.5%     +3.6%     +6.4%     +5.5%
 Geometric Mean          +0.2%     -3.0%     +0.2%     +0.4%



More information about the Glasgow-haskell-users mailing list