a compiled program is slower than byte code

Simon Marlow marlowsd at gmail.com
Tue Feb 8 12:21:02 CET 2011


 > If I compile the attach code with GHC of the newest ghc-7.0 darcs
 > branch, the compiled program is much slower than byte code. This
 > phenomenon does not exist in GHC 6.12.3.
 >
 > 6.12.3  runghc   -- 6.23s user 0.59s system 98% cpu 6.912 total
 >         ghc      -- 5.72s user 0.70s system 99% cpu 6.422 total
 >         ghc -O   -- 5.70s user 0.67s system 99% cpu 6.376 total
 >         ghc -O2  -- 5.69s user 0.67s system 99% cpu 6.373 total
 >
 > ghc-7.0 runghc   -- 6.43s user 0.10s system 99% cpu 6.593 total
 >         ghc      -- 9.20s user 0.09s system 99% cpu 9.302 total
 >         ghc -O   -- 9.20s user 0.09s system 99% cpu 9.298 total
 >         ghc -O2  -- 9.38s user 0.09s system 99% cpu 9.478 total
 >
 > Is this a bug?

I don't see the same results here (x86_64/Linux).  This is the 7.0 
branch built last night:

$ ghc-stable-nightly2 ./kazu.hs -O2 -fforce-recomp; time ./kazu
[1 of 1] Compiling Main             ( kazu.hs, kazu.o )
Linking kazu ...
8.58s real   8.54s user   0.04s system   99% ./kazu
$ time runghc -f ghc-stable-nightly2 ./kazu.hs -O2 -fforce-recomp;
16.92s real   14.21s user   2.70s system   99% runghc -f 
ghc-stable-nightly2 ./kazu.hs -O2 -fforce-recomp

However, there is a fairly large difference between the 7.0 branch and HEAD:

$ ghc-nightly2 ./kazu.hs -O2 -fforce-recomp; time ./kazu
[1 of 1] Compiling Main             ( kazu.hs, kazu.o )
Linking kazu ...
4.17s real   4.16s user   0.01s system   99% ./kazu


HEAD is more than twice as fast on this program.  Fusion not working, 
perhaps?

Cheers,
	Simon


 > My environment is Mac which runs Snow Leopard.
 >
 > --Kazu
 >
 > ----
 > import System.IO
 >
 > n :: Int
 > n = 10000
 >
 > main :: IO ()
 > main = withFile "/dev/null" WriteMode $ \h ->
 >     hPutStr h . foldr1 (++) . replicate n . replicate n $ 'a'
 > ----
	



More information about the Glasgow-haskell-users mailing list