#12313: Fix yet another memory leak caused by caching of coercion data
-------------------------+--------------------------------------------------
Reporter: SimonKing | Owner: rlm
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.0
Component: memleak | Keywords: coercion weak dictionary
Work_issues: | Upstream: N/A
Reviewer: | Author: Simon King
Merged: | Dependencies: #715
-------------------------+--------------------------------------------------
Changes (by newvalueoldvalue):
* status: new => needs_review
* author: => Simon King
Comment:
With the attached patch (to be applied after #715), a new kind of weak
dictionary is introduced, and used to cache coercions and conversions. All
tests pass for me.
Concerning raw speed: Without the patch, we have
{{{
sage: RDF.coerce_map_from(ZZ)
Native morphism:
From: Integer Ring
To: Real Double Field
sage: timeit("RDF.coerce_map_from(ZZ)",number=10^5)
100000 loops, best of 3: 518 ns per loop
}}}
With the patch, it is 466 ns, hence, one gains 10% in an operation that is
very frequent.
The total speed seems to be fine as well, `make ptest` has not been slower
than before.
Concerning memory leaks:
{{{
sage: import gc
sage: _ = gc.collect()
sage: K = GF(1<<55,'t')
sage: for i in range(50):
... a = K.random_element()
... E = EllipticCurve(j=a)
... b = K.has_coerce_map_from(E)
sage: _ = gc.collect()
sage: len([x for x in gc.get_objects() if isinstance(x,type(E))])
1
}}}
That is a new doctest and tests against a memory leak that has not been
fixed by #715.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12313#comment:4>
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.