#4065: Inconsistent loop performance
---------------------------------+------------------------------------------
Reporter: rl | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.13 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
---------------------------------+------------------------------------------
Here are two small benchmarks:
{{{
import Criterion.Main
foo :: Int -> Int -> Int
foo n k | n <= 0 = k
| otherwise = foo (n-1) (k+1)
bar :: Int -> Int -> Int
bar n k | n == 0 = k
| otherwise = bar (n-1) (k+1)
main :: IO ()
main = defaultMain [ bench "foo" $ nf (uncurry foo) (20000000,0)
, bench "bar" $ nf (uncurry bar) (20000000,0)
]
}}}
On my laptop, I consistently get a mean running time of about 36ms for
`foo` and about 45ms for `bar`. This is a rather big difference. The Core
looks about the same and going via C gives me about 42ms for both loops so
this is certainly a code generator problem.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4065>
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