[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] Re: Difference in Runtime but no explanation

Subject: Re: [Haskell-cafe] Re: Difference in Runtime but no explanation
From: Maciej Piechotka
Date: Tue, 15 Dec 2009 19:34:10 +0000
On Tue, 2009-12-15 at 10:56 -0800, Thomas DuBuisson wrote:
> On Tue, Dec 15, 2009 at 10:30 AM, Maciej Piechotka
> <[email protected]> wrote:
> > My results (ghc 6.12.1, Core 2 Duo 2.8 GHz, Linux 2.6.32, Gentoo):
> >
> > Not Optimized & not compiled:
> > First:  12.47 secs, 1530911440 bytes
> > Second: 17.40 secs, 1929614816 bytes
> > Optimized & compiled:
> > First:   1.24 secs, 966280832 bytes
> > Second:  1.11 secs, 966277152 bytes
> 
> Seconded, I consistently get 0.350 seconds vs 0.300 when compiling the
> original code via -O2.
> 
> > Repeating gave similar results - first being better w/out
> > optimalization as 1.2:1.7 and second being better with optimalizations (-O).
> >
> > Why the first one is better unoptimalized?
> 
> I think thats not a specific enough question.  I replaced the
> 'Integer' with 'Int' and found (via -ddump-asm) that the assembly is
> _identical_. A test shows what you would expect - the performance was
> identical.  So the question in my mind is what presumably trivial
> optimization doesn't happen when Integer is used?
> 
> Thomas

Ups. I forgot about types :(

                Integer
Not optimized & compiled:
First:  19.81 secs, 2774731128 bytes
Second: 22.64 secs, 3092270464 bytes
Optimized & compiled:
First:   0.64 secs, 980673088 bytes
Second:  0.65 secs, 975408024 bytes
                Int
Not optimized & compiled:
First:  19.60 secs, 2774208376 bytes
Second: 22.65 secs, 3092274608 bytes
Optimized & compiled:
First:   0.46 secs, 808978336 bytes
Second:  0.43 secs, 803460216 bytes

As for Integer. In case of Int l+1 `seq` something it can be simply
transformed into (pseudo-assembler):
call l
incq %rax ; Or addq $1, %rax
call something

But for Integer:
call l
movq $1, %rbx
call Integer.+
call something

Regards
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>