6.6.1 on long lists
Serge D. Mechveliani
mechvel at botik.ru
Sat Jun 30 04:15:56 EDT 2007
Dear GHC developers,
I tried to test the ghc-6.6.1 performance on long lists.
And there is something a bit suspicious about the test.
Consider the program
-----------------------------------------
main = putStr (shows res "\n")
where
n = k*10^6 :: Int
k = 2 -- put k = 2,4,6, ...
res = head $ rev [1 .. n]
rev xs = r [] xs where r xs [] = xs
r xs (y: ys) = r (y: xs) ys
-----------------------------------------
512 Mb RAM machine, Pentium 4, 1.6 GHz, Debian Linux.
`Making': ghc -O --make Main
Running time Main +RTS -M400m -RTS
---- ghc-6.6.1 -------------------|
k time [sec] minimal needed ghc-5.02.3
for 400Mb heap (-M..) [Mb]
2 1.3 41 2 sec 41 Mb
4 3.0
6 7.8
8 8.8 164 8
------------------
10 23.7
12 24.7 244
14 25.1 13
-----------------------------------------------------------------
Should the cost of this program be linear in k ?
For example:
8/4 = 2, time(8)/time(4) = 8.8/3.0 =~= 2.9
Should this ratio be near 2.0 ?
Further, at k = 10, the time jumps.
This is, probably, due to that a list of 10*10^6 ints takes about
8*10*10^6 bytes =~= 80 Mb (please, is this so ?),
the program may need a copy of this list ... and this total may be
close to -M400M (?),
and thus garbage collection happens (once).
After k = 10, it looks again like linear.
My impression is that at the segment k <- [2, 8] the cost is about
k*(log k).
Thank you in advance for your comments.
Regards,
-----------------
Serge Mechveliani
mechvel at botik.ru
More information about the Glasgow-haskell-users
mailing list