[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] Re: [Axiom-mail] A slow summation
From: |
Waldek Hebisch |
Subject: |
[Axiom-developer] Re: [Axiom-mail] A slow summation |
Date: |
Fri, 15 Jun 2007 13:28:46 +0200 (CEST) |
Bill Page wrote:
> On 15 Jun 2007 07:49:11 +0200, Martin Rubey wrote:
> >
> > > > reduce(+,[1.0/i for i in 1..20000])
> > > >
> > > > This works, but is (I think) unreasonably slow; it takes over 21
> > > > seconds on
> > > > my computer. The equivalent command in Maxima takes less than 1 second.
> >
> > Bill, could you file that as a bug on MathAction, please.
>
> Well, I would rather that somebody new do that. Alasdair? :-)
>
> The "issue" (I am not quite sure to call it a "bug") is probably some
> very inefficient implementation of list comprehension in the Axiom
> interpreter. E.g.
>
> (1) -> )set message time on
> (1) -> [i for i in 1..20000];
>
> Type: List PositiveInteger
> Time: 14.73 (EV) + 0.02 (OT) + 0.05 (GC) = 14.80 sec
>
> (2) -> expand(1..20000);
>
> Type: List Integer
> Time: 0.07 (IN) + 0.18 (OT) = 0.25 sec
>
> -------
>
> Both (1) and (2) do essentially the same thing.
>
> >
> > (If you have an sbcl compiled axiom available, you could check
> > whether it is gcl's fault, or rather a bug in axiom.)
> >
>
> I am quite sure that this is not a lisp implementation issue,
> but no I don't have a sbcl version of Axiom available. Do you?
> Still, maybe this is a job for someone who knows how to use
> the sbcl profiler to find out where the Axiom interpreter is
> spending all it's time - Waldek?
>
On my machine, I get the following (on the second run, to
exclude time for loading):
gcl sbcl sbcl
interpreted compiled
reduce(+,[1.0/i for i in 1..20000]) 8.70 1.76 0.17
[i for i in 1..20000]; 6.23 0.78 0.01
expand(1..20000); 0 0.004 0.01
Comment: sbcl evaluator has two modes of operation: interpreted
and compiled. In compiled mode the code is first compiled and
then the resulting machine code is run. One can switch mode
setting variable sb-ext:*evaluator-mode*:
)lisp (setf sb-ext:*evaluator-mode* :compile)
or
)lisp (setf sb-ext:*evaluator-mode* :interpret)
sbcl profiler showed that 98% of time were spent in Lisp evaluator,
and that agrees very well with getting much higher speed using
compiled mode.
--
Waldek Hebisch
address@hidden