Program with profiling runs faster than without

Hello! I can't understand why the following happens. ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run -prof -auto-all and time ./Run TestSim seems to be much faster (I got ~4 times faster indeed) than just ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run and time ./Run TestSim with ghc 6.8.2 on pentium 4 2.4 GHz under Ubuntu I was on my way to optimize the program when I've discovered this. The program is rather complicated and badly optimized but still I think it is quite strange to the profiled version to run faster. All necessary files I send with this letter (Tann.7z).

14.07.09, 12:37, "Grigory Sarnitskiy"
Hello! I can't understand why the following happens. ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run -prof -auto-all and time ./Run TestSim seems to be much faster (I got ~4 times faster indeed) than just ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run and time ./Run TestSim with ghc 6.8.2 on pentium 4 2.4 GHz under Ubuntu I was on my way to optimize the program when I've discovered this. The program is rather complicated and badly optimized but still I think it is quite strange to the profiled version to run faster. All necessary files I send with this letter (Tann.7z).
Well, I've tested the code with ghc 6.10.3 under Windows --- the result is quite the same, however with the native binary compilier (not via C) the redult is even more drastic. I'm really interested how to obtain the same speed withput profiling compilation.

On 14 Jul 2009, at 11:09, Grigory Sarnitskiy wrote:
I think it is quite strange to the profiled version to run faster
I'm really interested how to obtain the same speed withput profiling compilation.
This is only a guess, but maybe there is a context-qualified CAF-like value that is being re-evaluated multiple times in the non-profiling case, but is appropriately monomorphised in the profiling case, so it is only evaluated once? Regards, Malcolm
participants (2)
-
Grigory Sarnitskiy
-
Malcolm Wallace