a compiled program is slower than byte code
Simon Marlow
marlowsd at gmail.com
Wed Feb 9 10:20:14 CET 2011
On 09/02/2011 04:35, Kazu Yamamoto (山本和彦) wrote:
> Hello Simon,
>
>> $ 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
>
> OK. I ran it on 32bit Linux.
>
> 6.12.3 runghc -- 2.22s user 0.40s system 96% cpu 2.724 total
> ghc -- 1.96s user 0.14s system 97% cpu 2.151 total
> ghc -O -- 2.18s user 0.10s system 97% cpu 2.333 total
> ghc -O2 -- 2.27s user 0.07s system 97% cpu 2.393 total
>
> ghc-7.0 runghc -- 3.43s user 0.35s system 97% cpu 3.861 total
> ghc -- 5.11s user 0.07s system 97% cpu 5.299 total
> ghc -O -- 5.38s user 0.03s system 97% cpu 5.534 total
> ghc -O2 -- 5.54s user 0.10s system 97% cpu 5.783 total
Thanks, I do see the problem now (I was inadvertently running the
compiled code with runghc, because I used "runghc foo.hs
-fforce-recomp", which doesn't do what I thought it did).
I created a ticket: http://hackage.haskell.org/trac/ghc/ticket/4951
I think the difference between interpreted and compiled is due to
http://hackage.haskell.org/trac/ghc/ticket/917. What I'm more worried
about is the slowdown in pre-7.0.2 relative to other versions.
>> HEAD is more than twice as fast on this program. Fusion not working,
>> perhaps?
>
> Here is the results of "ghc -O -ddump-simpl-stats":
>
> ghc-7.0:
>
> 19 RuleFired
> 6 ++
> 2<=#
> 1 fold/build
> 5 foldr/app
> 1 foldr/augment
> 1 foldr/single
> 1 map
> 1 unpack
> 1 unpack-list
>
> 6.12.3:
>
> 25 RuleFired
> 6 ++
> 2<=#
> 3 fold/build
> 6 foldr/app
> 1 foldr/augment
> 1 map
> 2 repeat
> 2 take
> 1 unpack
> 1 unpack-list
My stats look very different.
6 RuleFired
1 ++
2 <=#
1 foldr/app
1 unpack
1 unpack-list
Are your libraries compiled with -O2?
Cheers,
Simon
More information about the Glasgow-haskell-users
mailing list