[GHC] #8766: length [Integer] is twice as slow but length [Int] is 10 times faster
GHC
ghc-devs at haskell.org
Tue Feb 11 02:26:35 UTC 2014
#8766: length [Integer] is twice as slow but length [Int] is 10 times faster
------------------------------+--------------------------------------------
Reporter: George | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.1-rc1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime performance bug
Unknown/Multiple | Test Case:
Difficulty: Unknown | Blocking:
Blocked By: |
Related Tickets: |
------------------------------+--------------------------------------------
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)]
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8766>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list