length [Integer] is twice as slow but length [Int] is 10 times faster
Compared to 7.6.3 length in 7.8.1-rc1 has a performance regression:
ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.20140130
bash-3.2$ ghc -O2 LengthIntegerList.hs
[1 of 1] Compiling Main ( LengthIntegerList.hs, LengthIntegerList.o )
Linking LengthIntegerList ...
bash-3.2$ time ./LengthIntegerList
1073741824
real 0m45.344s
user 0m44.230s
sys 0m0.494s
bash-3.2$ /usr/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
bash-3.2$ /usr/bin/ghc -O2 LengthIntegerList.hs
[1 of 1] Compiling Main ( LengthIntegerList.hs, LengthIntegerList.o )
Linking LengthIntegerList ...
bash-3.2$ time ./LengthIntegerList
1073741824
real 0m22.769s
user 0m22.042s
sys 0m0.385s
bash-3.2$ cat LengthIntegerList.hs
{-# OPTIONS_GHC -Wall #-}
module Main where
main :: IO()
main = print $ length [1..(2^(30::Int)::Integer)]
thus length of [Integer] is twice as slow in rc1 but length of [Int] is 10 times faster:
ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.20140130
bash-3.2$ ghc -O2 LengthIntList.hs
[1 of 1] Compiling Main ( LengthIntList.hs, LengthIntList.o )
Linking LengthIntList ...
bash-3.2$ time ./LengthIntList
1073741824
real 0m0.723s
user 0m0.693s
sys 0m0.003s
bash-3.2$ /usr/bin/ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
bash-3.2$ /usr/bin/ghc -O2 LengthIntList.hs
[1 of 1] Compiling Main ( LengthIntList.hs, LengthIntList.o )
Linking LengthIntList ...
bash-3.2$ time ./LengthIntList
1073741824
real 0m11.805s
user 0m10.900s
sys 0m0.351s
bash-3.2$ cat LengthIntList.hs
{-# OPTIONS_GHC -Wall #-}
module Main where
main :: IO()
main = print $ length [1..(2^(30::Int)::Int)]
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.1-rc1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |