#1957: Program that runs slower with optimizations on
-------------------------+--------------------------------------------------
Reporter: clanehin | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.8.1
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: x86 | Os: Linux
-------------------------+--------------------------------------------------
This program runs significantly slower with optimization than without.
I need two modules to manifest this bug.
Is this a duplicate of 917/1945? Using -fno-full-laziness does not
mitigate the problem.
This seems to be the opposite of 1945. Without optimizations, there is a
long delay and then all 10 results print at once. With optimizations,
there is a shorter delay between each print statement.
module Main
(main)
where
import NaiveFib
import Control.Monad
main :: IO ()
main = replicateM_ 10 (printFib 37)
module NaiveFib
(printFib,naiveFib)
where
printFib :: Integer -> IO ()
printFib = print . naiveFib
naiveFib :: Integer -> Integer
naiveFib 0 = 0
naiveFib 1 = 1
naiveFib n = naiveFib (n-1) + naiveFib (n-2)
[EMAIL PROTECTED]:~/test/optimizer-bug$ make main-O0
ghc-6.8.1 -O0 --make Main.hs -o main-O0
[1 of 2] Compiling NaiveFib ( NaiveFib.hs, NaiveFib.o )
[2 of 2] Compiling Main ( Main.hs, Main.o )
Linking main-O0 ...
[EMAIL PROTECTED]:~/test/optimizer-bug$ time ./main-O0
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
real 0m34.491s
user 0m25.982s
sys 0m0.564s
[EMAIL PROTECTED]:~/test/optimizer-bug$ make main-O2
ghc-6.8.1 -O2 --make Main.hs -o main-O2
[1 of 2] Compiling NaiveFib ( NaiveFib.hs, NaiveFib.o )
[2 of 2] Compiling Main ( Main.hs, Main.o )
Linking main-O2 ...
[EMAIL PROTECTED]:~/test/optimizer-bug$ time ./main-O2
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
24157817
real 1m50.331s
user 1m23.641s
sys 0m1.008s
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1957>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs