#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):
Above, I mentioned `ZZ.ideal(5)` becoming slower and slower with each
iteration. I can narrow it down a bit more
With sage-5.3.beta2, #12313 and the patches from here, I get
{{{
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 46.2 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 49 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 50.4 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 52.4 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 54.7 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 56 µs per loop
}}}
In ''unpatched'' sage-5.3.beta2, one gets
{{{
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 15.9 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 15.8 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 38.5 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 38.5 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 25.4 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 15.8 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 15.8 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 29.8 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 15.9 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 35.3 µs per loop
}}}
I thought this was supposed to be fixed with #13370. but sage-5.3.beta2
plus #12313 plus the patches from here plus #13370 yields:
{{{
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 47.1 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 49.1 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 51.1 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 53.4 µs per loop
sage: %timeit ZZ.has_coerce_map_from(5)
625 loops, best of 3: 54.7 µs per loop
}}}
My impression is that, again, caching is to blame. Namely, since the weak
caches from #715 and #12313 compare by identity, not equality, repeating
`ZZ.has_coerce_map_from(5)` does put many copies of 5 into the cache
(integers are not unique).
But have we not recently dealt with the same problem on another ticket? I
currently can't find it.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13400#comment:30>
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.