#6818: [with patch; needs review] maxima interface gets dramatically slower over
time
------------------------+---------------------------------------------------
 Reporter:  was         |       Owner:  was       
     Type:  defect      |      Status:  new       
 Priority:  critical    |   Milestone:  sage-4.1.2
Component:  interfaces  |    Keywords:            
 Reviewer:              |      Author:            
   Merged:              |  
------------------------+---------------------------------------------------
Description changed by was:

Old description:

> If you do a few hundred calls to the maxima interface, it gets way way
> slower.
>
> {{{
> sage: timeit("str(maxima.eval('1+2'))")
> 5 loops, best of 3: 758 µs per loop
> sage: timeit("str(maxima.eval('1+2'))")
> 625 loops, best of 3: 1.22 ms per loop
> sage: timeit("str(maxima.eval('1+2'))")
> 125 loops, best of 3: 2.98 ms per loop
> sage: timeit("str(maxima.eval('1+2'))")
> 125 loops, best of 3: 3.97 ms per loop
> }}}
>
> It turns out that this is caused by computation of the maxima input
> prompt number, which uses the following "clever" algorithm to compute
> "n+1":
>
> {{{
> (defmfun makelabel (x)
>   (when (and $dskuse (not $nolabels) (> (incf dcount) $filesize))
>     (setq dcount 0)
>     (dsksave))
>   (setq linelable ($concat '|| x $linenum))
>   (unless $nolabels
>     (when (or (null (cdr $labels))
>               (when (member linelable (cddr $labels) :test #'equal)
>                 (setf $labels (delete linelable $labels :count 1 :test
> #'eq)) t)
>               (not (eq linelable (cadr $labels))))
>       (setq $labels (cons (car $labels) (cons linelable (cdr
> $labels))))))
>   linelable)
> }}}
>
> More precisely, this code "checks
> that the list containing all labels does not contain the new label
> which it generates. After you create 2*35150 labels, this takes longer
> than when maxima starts.", according to Andrej Vodopivec who tracked this
> down and told us a simple fix.  Put:
>
> {{{
> nolabels:true;
> }}}
>
> at the beginning of our Maxima session.  This is fine for Sage, since
> Sage doesn't use the labels in any way.

New description:

 If you do a few hundred calls to the maxima interface, it gets way way
 slower.

 {{{
 sage: timeit("str(maxima.eval('1+2'))")
 5 loops, best of 3: 758 µs per loop
 sage: timeit("str(maxima.eval('1+2'))")
 625 loops, best of 3: 1.22 ms per loop
 sage: timeit("str(maxima.eval('1+2'))")
 125 loops, best of 3: 2.98 ms per loop
 sage: timeit("str(maxima.eval('1+2'))")
 125 loops, best of 3: 3.97 ms per loop
 }}}

 It turns out that this is caused by computation of the maxima input prompt
 number, which uses the following "clever" algorithm to compute "n+1":

 {{{
 (defmfun makelabel (x)
   (when (and $dskuse (not $nolabels) (> (incf dcount) $filesize))
     (setq dcount 0)
     (dsksave))
   (setq linelable ($concat '|| x $linenum))
   (unless $nolabels
     (when (or (null (cdr $labels))
               (when (member linelable (cddr $labels) :test #'equal)
                 (setf $labels (delete linelable $labels :count 1 :test
 #'eq)) t)
               (not (eq linelable (cadr $labels))))
       (setq $labels (cons (car $labels) (cons linelable (cdr $labels))))))
   linelable)
 }}}

 More precisely, this code "checks
 that the list containing all labels does not contain the new label
 which it generates. After you create 2*35150 labels, this takes longer
 than when maxima starts.", according to Andrej Vodopivec and Robert Dodier
 who (independently) tracked this down and told us a simple fix.  Put:

 {{{
 nolabels:true;
 }}}

 at the beginning of our Maxima session.  This is fine for Sage, since Sage
 doesn't use the labels in any way.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6818#comment:1>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to