#13400: Use strong caches diligently
-------------------------------+--------------------------------------------
       Reporter:  nbruin       |         Owner:  robertwb     
           Type:  enhancement  |        Status:  new          
       Priority:  major        |     Milestone:  sage-wishlist
      Component:  coercion     |    Resolution:               
       Keywords:               |   Work issues:               
Report Upstream:  N/A          |     Reviewers:               
        Authors:               |     Merged in:               
   Dependencies:               |      Stopgaps:               
-------------------------------+--------------------------------------------

Comment (by SimonKing):

 I think the ticket description is a bit too broad. I hope you don't mind
 that I change the title? If you do, please change back.

 The reason for the name change I'm suggesting is the observation that
 quite some objects are created during startup of Sage, and are then
 garbage collected before even the Sage prompt appears. I think that this
 indicates potential trouble. I find the following with
 sage-5.2.beta3+#12313 and its dependencies:

 When Sage starts, 37 different objects appearing as ''values'' in a weak
 value dictionary get removed. Some of the deleted values occur 4 or 8
 times. In particular, the "Groupoid with underlying set Symbolic Ring" is
 deleted 3 times, and the "Groupoid with underlying set Rational Field" is
 deleted 8 times, before sage even starts. In addition, both CIF['x'] and
 CC['x'] are created and deleted twice.

 Perhaps one should emphasize that `UniqueRepresentation` and
 `UniqueFactory` actually were supposed to have a weak cache, according to
 the documentation. Nevertheless, some code relies on the fact (the bug)
 that the documentation was misleading and the cache has been strong.

 Would it be useful to have a switch for `TripleDict` and `MonoDict`, such
 as `strong_cache_on()`, `strong_cache_off()`? The idea is that after
 calling `strong_cache_on()`, every item put into a `TripleDict` or
 `MonoDict` and every item created by `weak_cached_function` (such as
 `UniqueRepresentation`) and every item created with `UniqueFactory` is
 prevented from deletion by adding a strong reference, and
 `strong_cache_off()` deletes the strong references created since last
 calling `strong_cache_on()`, so that only the weak references remain and
 stuff becomes collectable?

 Perhaps that could even become a context, so that the computation of the
 echelon form could be like
 {{{
    with strong_cache:
       <the multimodular code>
 }}}

 Concerning startup, I think 37 objects are easy to take care of. Perhaps
 one should add a strong reference to them in the modules creating them.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13400#comment:2>
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.

Reply via email to