guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile performance - Ackermann function: way slower than emacs, slow


From: Andy Wingo
Subject: Re: guile performance - Ackermann function: way slower than emacs, slower still if compiled
Date: Thu, 06 Aug 2009 17:59:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Hi,

On Wed 05 Aug 2009 12:42, Andy Wingo <address@hidden> writes:

> The simple stack formulation of Ackermann's function is faster of
> course:
>
>     (define (A m n)
>       (if (= m 0)
>           (+ n 1)
>           (if (= n 0)
>               (A (- m 1) 1)
>               (A (- m 1) (A m (- n 1))))))
>
> (A 3 9) completes in 1.45 seconds for me. 
>
> Curiously, the letrec case takes more time:
>
>     (define (A m n)
>       (let A ((m m) (n n))
>         (if (= m 0)
>             (+ n 1)
>             (if (= n 0)
>                 (A (- m 1) 1)
>                 (A (- m 1) (A m (- n 1)))))))
>
> It should be faster, because we don't have to deref the toplevel
> variable for A, but the compiler needs to be a little smarter. This
> version takes about 1.6 seconds for me.

I have fixed this issue. The letrec version now takes slightly less time
than the version that recurses through the toplevel.

>> % time guile -c '(begin (load-compiled "ack.go") (ackermann 3 9))'
>> 48.728u 22.016s 1:10.75 99.9%        0+0k 0+0io 0pf+0w
>
> Indeed, I get similar times (44 seconds; presumably some of the
> compilation fixes actually had an effect).

This one now takes very, very marginally less time now (about a second) -- not
much of an improvement, but I wanted to take care of it before taking
catch / dynamic-wind.

Thanks,

Andy
-- 
http://wingolog.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]