#10296: Singular interface wasting time by waiting for the prompt too often
--------------------------+-------------------------------------------------
Reporter: SimonKing | Owner: was
Type: defect | Status: needs_review
Priority: major | Milestone: sage-4.6.1
Component: interfaces | Keywords: Singular, _eval_line,
synchronization, synchronisation
Author: Simon King | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
--------------------------+-------------------------------------------------
Changes (by newvalueoldvalue):
* status: new => needs_review
* author: => Simon King
Comment:
My patch does the following.
'''__Garbage Collection__'''
In the Singular interface, freeing the memory used for old variables in
Singular requires to send a "kill" command to Singular, presumably by
_eval_line.
A problem would result if garbage collection would create such _eval_line
inside an outer _eval_line: The inner _eval_line would cause the outer
_eval_line to hang forever. I guess this was the reason why the del method
does not actually delete the variables but only marks them for deletion;
the actual deletion is postponed to the next use of "eval".
I guess that for the same reason, synchronisation is done at the beginning
of "eval". '''Please correct me, if the reason for synchronising so
frequently is different!'''
I suggest to do the deletions a bit less frequently, namely in the "set"
method rather than in the "eval" method. Moreover, I suggest to send the
kill command not by a separate _eval_line (one for each old variable), but
to prepend the join of all kill commands to the command that creates the
new variable.
Since killing does not require an additional _eval_line, nesting can not
occur. So, synchronisation is not needed.
'''__Overhead Reduction__'''
As mentioned in the ticket description, calling _eval_line frequently is
bad, since waiting for the Singular prompt in the output of a pseudo
terminal produces a massive overhead (up to 22ms per call) on some
machines.
My patch removes synchronisation (which avoids one call to _eval_line per
call to eval), and killing old variables does not require any additional
_eval_line. So, in the example proposed in the ticket description, the
wall time drops by 2/3!
'''__Miscellaneous__'''
Synchronisation used to fail with an `AttributeError` for the GAP
interface. It is fixed by the patch.
I tried to make everything more stable, by giving more opportunities to
detect that the interface crashed, and restarting if necessary.
Of course, I added documentation and tests that (I think) cover all issues
mentioned here. Moreover, I added tests covering some optional arguments
to _eval_line.
For me, {{{sage -testall}}} passes. Hence, ready for review!
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10296#comment:3>
Sage <http://www.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.