[Haskell-cafe] -O2 compile option can give speed increase over -O. Fasta shootout program test runs.

Richard Kelsall r.kelsall at millstream.com
Mon Jul 16 14:49:54 EDT 2007


I have been playing with the Fasta program in the shootout to see if
I can make it umm faster. Starting from dons program on this page and
adding some timing calculations as suggested on this wiki page

http://shootout.alioth.debian.org/gp4/benchmark.php?test=fasta&lang=ghc&id=2
http://www.haskell.org/haskellwiki/Timing_computations

I added different OPTIONS into the top line of the program did a
ghc --make fasta.hs   and ran it each time with  fasta 2500000
(This is one tenth of the shootout figure.) These runs all keep the
existing OPTIONS of  -fbang-patterns -fexcess-precision

   Seconds   OPTIONS Added
   -------   -------------
    40.5
    40.5        -funbox-strict-fields
    40.4                      {-# INLINE rand #-}
    17.2        -O
    17.0        -O  -fvia-C
    14.4        -O  -optc-march=pentium4
    11.5        -O2
    11.2        -O3
    11.5        -O3           {-# INLINE rand #-}
    11.3        -O2 -optc-march=pentium4

There was a bit of variation, I've averaged over two runs. This is on
an Intel Pentium D 2.66GHz running W2K and GHC 6.6.1.

It seems the -O2 option can give a significant speed increase relative
to just the -O option. This is contrary to the documentation which says

http://www.haskell.org/ghc/docs/latest/html/users_guide/options-optimise.html
http://www.haskell.org/ghc/docs/latest/html/users_guide/faster.html

it won't make any difference. I guess it's program, architecture and
operating system specific, but according to these figures the -O2 option
seems well worth a try for programs that need speed. It may be that
we sacrifice bounds checking or something important with -O2, I don't
know.


Richard.



More information about the Haskell-Cafe mailing list