#13991: Mitigate speed regressions in symmetric function related code due to 
#12313
---------------------------------+------------------------------------------
       Reporter:  nbruin         |         Owner:  sage-combinat
           Type:  enhancement    |        Status:  new          
       Priority:  major          |     Milestone:  sage-5.7     
      Component:  combinatorics  |    Resolution:               
       Keywords:                 |   Work issues:               
Report Upstream:  N/A            |     Reviewers:               
        Authors:                 |     Merged in:               
   Dependencies:                 |      Stopgaps:               
---------------------------------+------------------------------------------
Description changed by jdemeyer:

Old description:

> As was found in #12313, there is some code that has to do with symmetric
> functions, especially `k_dual.py`, that seems to be extremely reliant for
> its performance on parents being immortal:
> {{{
> sage: from sage.combinat.sf.k_dual import DualkSchurFunctions
> sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())
> sage: dks4 = DualkSchurFunctions(Sym.kBoundedQuotient(4))
> sage: X=dks4[0]+ 2*dks4[1] + 3*dks4[2]
> sage: X*X #takes surprisingly long with #12313 applied
> sage: (X*X)*X #takes surprisingly long with #12313 applied
> }}}
> Profiling gives some indication what is happening:
> {{{
> sage: import cProfile,pstats
> sage: cmd = "X*X"
> sage: s=pstats.Stats(cProfile.Profile().runctx(cmd,globals(),{}))
> sage: S=s.sort_stats('cumulative')
> sage: S.print_callers() # get call graph info
> }}}
> it seems certain parents are created again and again and the coercion
> discoveries need to be redone every time.
>
> Probably, the most straightforward solution is to equip the classes with
> appropriate caches so that they themselves are now ensuring the lifetime
> of parents they use rather than rely on sage to keep them around.

New description:

 As was found in #12313, there is some code, especially `k_dual.py`
 introduced in #13762, that seems to be extremely reliant for its
 performance on parents being immortal:
 {{{
 sage: from sage.combinat.sf.k_dual import DualkSchurFunctions
 sage: Sym = SymmetricFunctions(QQ['t'].fraction_field())
 sage: dks4 = DualkSchurFunctions(Sym.kBoundedQuotient(4))
 sage: X=dks4[0]+ 2*dks4[1] + 3*dks4[2]
 sage: X*X #takes surprisingly long with #12313 applied
 sage: (X*X)*X #takes surprisingly long with #12313 applied
 }}}
 Profiling gives some indication what is happening:
 {{{
 sage: import cProfile,pstats
 sage: cmd = "X*X"
 sage: s=pstats.Stats(cProfile.Profile().runctx(cmd,globals(),{}))
 sage: S=s.sort_stats('cumulative')
 sage: S.print_callers() # get call graph info
 }}}
 it seems certain parents are created again and again and the coercion
 discoveries need to be redone every time.

 Probably, the most straightforward solution is to equip the classes with
 appropriate caches so that they themselves are now ensuring the lifetime
 of parents they use rather than rely on sage to keep them around.

--

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