#715: Parents probably not reclaimed due to too much caching
--------------------------------------------------------------------+-------
       Reporter:  robertwb                                          |         
Owner:  somebody                                 
           Type:  defect                                            |        
Status:  closed                                   
       Priority:  major                                             |     
Milestone:  sage-5.5                                 
      Component:  coercion                                          |    
Resolution:  fixed                                    
       Keywords:  weak cache coercion Cernay2012                    |   Work 
issues:                                           
Report Upstream:  N/A                                               |     
Reviewers:  Jean-Pierre Flori, Simon King, Nils Bruin
        Authors:  Simon King, Jean-Pierre Flori                     |     
Merged in:  sage-5.5.beta0                           
   Dependencies:  #13145, #13741, #13746, to be merged with #11521  |      
Stopgaps:                                           
--------------------------------------------------------------------+-------

Comment (by SimonKing):

 Without #715 and friends,
 {{{
 sage: %prun p = polar_plot(lambda t:
 (100/(100+(t-pi/2)^8))*(2-sin(7*t)-cos(30*t)/2), -pi/4, 3*pi/2,
 color="red",plot_points=1000)
 }}}
 yields
 {{{
    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     88368   12.267    0.000   20.873    0.000 arith.py:1439(gcd)
      9263    9.309    0.001   32.102    0.003 <string>:1(<lambda>)
 79788/39894    2.004    0.000    2.865    0.000
 lazy_attribute.py:506(__get__)
     39894    1.599    0.000    4.681    0.000 homset.py:296(__init__)
     97631    1.145    0.000    1.737    0.000 arith.py:1611(lcm)
     19950    0.961    0.000    6.910    0.000 homset.py:40(Hom)
    185999    0.879    0.000    0.880    0.000 {method 'canonical_coercion'
 of 'sage.structure.coerce.CoercionModel_cache_maps' objects}
  8263/999    0.824    0.000   29.602    0.030
 plot.py:2307(adaptive_refinement)
     39895    0.373    0.000    1.783    0.000 {hasattr}
    159576    0.328    0.000    0.328    0.000 {getattr}
     14601    0.309    0.000    0.510    0.000 quotient_fields.py:55(gcd)
     39890    0.304    0.000    5.033    0.000 homset.py:573(__init__)
    116811    0.259    0.000    0.259    0.000 weakref.py:55(__getitem__)
 }}}

 With #715, it becomes
 {{{
    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     89840   43.019    0.000   68.180    0.001 arith.py:1489(gcd)
      9415   24.524    0.003   97.043    0.010 <string>:1(<lambda>)
 82004/41002    5.752    0.000    7.564    0.000
 lazy_attribute.py:506(__get__)
     41002    4.583    0.000   12.597    0.000 homset.py:353(__init__)
     20504    4.108    0.000   19.894    0.001 homset.py:80(Hom)
    189095    2.924    0.000    2.925    0.000 {method 'canonical_coercion'
 of 'sage.structure.coerce.CoercionModel_cache_maps' objects}
     99255    2.392    0.000    3.942    0.000 arith.py:1661(lcm)
  8415/999    1.517    0.000   88.121    0.088
 plot.py:2316(adaptive_refinement)
    205132    1.118    0.000    1.699    0.000 weakref.py:223(__new__)
    164064    1.088    0.000    1.088    0.000 weakref.py:228(__init__)
     41003    0.979    0.000    5.099    0.000 {hasattr}
    205132    0.581    0.000    0.581    0.000 {built-in method __new__ of
 type object at 0x7f9b33e874a0}
    164008    0.578    0.000    0.578    0.000 {getattr}
     40998    0.546    0.000   13.200    0.000 homset.py:630(__init__)
    119635    0.545    0.000    0.545    0.000 weakref.py:55(__getitem__)
     14954    0.532    0.000    0.813    0.000 quotient_fields.py:55(gcd)
     20499    0.424    0.000    8.366    0.000 rings.py:635(__new__)
    133072    0.394    0.000    0.394    0.000
 rational_field.py:217(__hash__)
    114209    0.370    0.000    0.370    0.000 {method 'lcm' of
 'sage.structure.element.PrincipalIdealDomainElement' objects}
     40998    0.332    0.000   13.532    0.000 homset.py:30(__init__)
     20499    0.330    0.000    0.330    0.000
 dynamic_class.py:122(dynamic_class)
     20499    0.304    0.000    7.942    0.000 homset.py:23(RingHomset)
    119748    0.297    0.000    0.297    0.000 {method 'gcd' of
 'sage.rings.integer.Integer' objects}
    189095    0.262    0.000    0.262    0.000
 {sage.structure.element.get_coercion_model}
     61551    0.213    0.000    0.213    0.000 {isinstance}
     41002    0.204    0.000    5.303    0.000
 sets_cat.py:255(_element_constructor_)
         1    0.201    0.201   98.842   98.842
 plot.py:2401(generate_plot_points)
 }}}

 So, it seems to me that the slow-down is in the creation of homsets.

 First question: Why are so many homsets needed in this example?

 Second question: What can we do to make the creation of a homset more
 efficient?

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