#15367: Empty lists while creating parents
---------------------------+-------------------------
       Reporter:  roed     |        Owner:
           Type:  defect   |       Status:  new
       Priority:  major    |    Milestone:  sage-5.13
      Component:  memleak  |   Resolution:
       Keywords:           |    Merged in:
        Authors:           |    Reviewers:
Report Upstream:  N/A      |  Work issues:
         Branch:           |       Commit:
   Dependencies:           |     Stopgaps:
---------------------------+-------------------------

Comment (by nbruin):

 These are the empty buckets of the various `TripleDict` and `MonoDict`
 data structures:
 {{{
 sage: import gc
 sage: pre = gc.get_objects()
 sage: K = Qp(7,2)
 sage: post = gc.get_objects()
 sage: len(post) - len(pre)
 682
 sage: pre_id=set( id(p) for p in pre )
 sage: new=[p for p in post if id(p) not in pre_id and isinstance(p,list)
 and len(p) ==0]
 }}}
 OK, we have now all the new lists of length 1. Let's see who's referring
 to them
 {{{
 sage: refs=[]
 sage: for p in new: refs.extend(gc.get_referrers(p))
 }}}
 and count, among the referrers that are lists themselves, what the lengths
 are.
 {{{
 sage: from collections import Counter
 sage: Counter(len(l) for l in refs if isinstance(l,list))
 Counter({525: 525, 117431: 525, 53: 265, 23: 228})
 }}}
 The first one must be `new` itself and the one of length `117431` also
 seems to contain all 525 of them. The other ones have conspicuous lengths:
 53 and 23:
 {{{
 sage: search_src("TripleDict\(23\)")
 structure/parent.pyx:684:            self._action_hash = TripleDict(23)
 structure/parent_old.pyx:87:        self._action_hash = TripleDict(23)
 sage: search_src("MonoDict\(23\)")
 structure/parent_gens.pyx:254:        self._has_coerce_map_from =
 MonoDict(23)
 structure/parent.pyx:682:            self._coerce_from_hash = MonoDict(23)
 structure/parent_old.pyx:85:        self._coerce_from_hash = MonoDict(23)
 structure/parent_old.pyx:100:        self._has_coerce_map_from =
 MonoDict(23)
 structure/parent_old.pyx:343:            self._has_coerce_map_from =
 MonoDict(23)
 sage: search_src("MonoDict\(53\)")
 structure/parent.pyx:686:            self._convert_from_hash =
 MonoDict(53)
 }}}
 so it looks like we have 265/53=5 (empty) `self._convert_from_hash`
 dictionaries and 228/23=9.9, so probably 10 (mostly) empty
 `self._coerce_from_hash` and `self._action_hash` dictionaries. Did we
 create 5 parents, perhaps?

 If you think this is a real issue, we could open-code the hashtables for
 `MonoDict` and `TripleDict` in the same way that `dict` is done. That's
 quite a bit of work to program correctly, though! In the mean time, we
 could reduce the default sizes of the dictionaries a bit. Perhaps 53 and
 23 is a bit on the large side for dictionaries that tend to not fill up so
 much?

--
Ticket URL: <http://trac.sagemath.org/ticket/15367#comment:1>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to