#12357: Make groupoids garbage collectable
-------------------------+--------------------------------------------------
   Reporter:  SimonKing  |          Owner:  rlm         
       Type:  defect     |         Status:  needs_review
   Priority:  major      |      Milestone:  sage-5.0    
  Component:  memleak    |       Keywords:              
Work_issues:             |       Upstream:  N/A         
   Reviewer:             |         Author:  Simon King  
     Merged:             |   Dependencies:  #12313      
-------------------------+--------------------------------------------------

Comment(by SimonKing):

 Concerning timings:

 Without the patch, the groupoid of P is stored in a dictionary, indexed by
 P. Hence, access to the cache is slow if `hash(P)` is slow.

 Some data points:
 {{{
 sage: P = GF(151)['x','y']
 sage: %timeit G = Groupoid(P)  # slow hash
 625 loops, best of 3: 20.9 µs per loop
 sage: %timeit G = Groupoid(ZZ) # fast hash
 625 loops, best of 3: 1.75 µs per loop
 sage: class Bar(Parent): pass
 ....:
 sage: P = Bar()
 sage: %timeit G = Groupoid(P)  # slow hash
 625 loops, best of 3: 15.3 µs per loop
 }}}

 But with the patch, it is stored as an attribute of P. Hence, it is slow
 if attribute access is slow. The point is that even slow attribute access
 is faster than slow hash, and slow attribute access is only little slower
 than fast hash:
 {{{
 sage: P = GF(151)['x','y']
 sage: %timeit G = Groupoid(P)  # slow attribute access
 625 loops, best of 3: 3.11 µs per loop
 sage: %timeit G = Groupoid(ZZ) # slow attribute access
 625 loops, best of 3: 3.1 µs per loop
 sage: class Bar(Parent): pass
 ....:
 sage: P = Bar()
 sage: %timeit G = Groupoid(P)  # fast attribute access
 625 loops, best of 3: 1.59 µs per loop
 }}}

 Hence, I believe that the patch is not only fixing a memory leak, but has
 the potential to generate a speed-up.

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

Reply via email to