Opened 11 years ago
Closed 11 years ago
#6818 closed defect (fixed)
[with patch, positive review] maxima interface gets dramatically slower over time
Reported by: | was | Owned by: | was |
---|---|---|---|
Priority: | critical | Milestone: | sage-4.1.2 |
Component: | interfaces | Keywords: | |
Cc: | Merged in: | Sage 4.1.2.alpha0 | |
Authors: | William Stein | Reviewers: | Alex Ghitza |
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
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.
NOTE: This is the same problem as #4731, so close that one too when this is closed.
Attachments (1)
Change History (5)
comment:1 Changed 11 years ago by
- Description modified (diff)
Changed 11 years ago by
comment:2 Changed 11 years ago by
- Description modified (diff)
comment:3 Changed 11 years ago by
- Summary changed from [with patch; needs review] maxima interface gets dramatically slower over time to [with patch; positive review] maxima interface gets dramatically slower over time
comment:4 Changed 11 years ago by
- Merged in set to Sage 4.1.2.alpha0
- Resolution set to fixed
- Reviewers set to Alex Ghitza
- Status changed from new to closed
- Summary changed from [with patch; positive review] maxima interface gets dramatically slower over time to [with patch, positive review] maxima interface gets dramatically slower over time
Looks good.