Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance improvement of mutable poset used for univariate asymptotic expansions #19577

Closed
dkrenn opened this issue Nov 12, 2015 · 8 comments
Closed

Comments

@dkrenn
Copy link
Contributor

dkrenn commented Nov 12, 2015

Reduce the evaluation time of the topological iterator.

As a result the time evaluating

k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)

(see #19306) dramatically decreases (see comment below for some timings).

CC: @behackl @cheuberg

Component: asymptotic expansions

Author: Daniel Krenn

Branch/Commit: b2af8aa

Reviewer: Clemens Heuberger

Issue created by migration from https://trac.sagemath.org/ticket/19577

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 12, 2015

Branch: u/dkrenn/asy/speed-topo-iter

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 12, 2015

New commits:

b2af8aatest whether sorting is needed in topological iteration

@dkrenn
Copy link
Contributor Author

dkrenn commented Nov 12, 2015

Commit: b2af8aa

@dkrenn dkrenn changed the title performance improvment of mutable poset used for univariate asymptotic expansions performance improvement of mutable poset used for univariate asymptotic expansions Nov 12, 2015
@dkrenn

This comment has been minimized.

@dkrenn
Copy link
Contributor Author

dkrenn commented Jan 27, 2016

comment:5

Before this patch:

sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
/local/dakrenn/sage/7.0/local/lib/python2.7/site-packages/sage/structure/unique_representation.py:1021: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/17601 for details.
  instance = typecall(cls, *args, **options)
/local/dakrenn/sage/7.0/local/lib/python2.7/site-packages/sage/rings/asymptotic/growth_group_cartesian.py:305: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/17601 for details.
  GenericGrowthGroup.__init__(self, sets[0], Vars, self.category(), **kwds)
1 loops, best of 1: 1.95 s per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 1.45 s per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 1.48 s per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 1.46 s per loop

After this patch:

sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
/local/dakrenn/sage/7.0/local/lib/python2.7/site-packages/sage/structure/unique_representation.py:1021: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/17601 for details.
  instance = typecall(cls, *args, **options)
/local/dakrenn/sage/7.0/local/lib/python2.7/site-packages/sage/rings/asymptotic/growth_group_cartesian.py:305: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/17601 for details.
  GenericGrowthGroup.__init__(self, sets[0], Vars, self.category(), **kwds)
1 loops, best of 1: 1.12 s per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 543 ms per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 546 ms per loop
sage: %timeit -n 1 -r 1 k=4; S = asymptotic_expansions.Stirling('n', precision=5); n = S.parent().gen(); S.subs(n=k*n) / (S.subs(n=(k-1)*n) * S)
1 loops, best of 1: 514 ms per loop

@cheuberg
Copy link
Contributor

comment:6

I can reproduce the speed-up in this particular instance and I cannot imagine bad side effects.

@cheuberg
Copy link
Contributor

Reviewer: Clemens Heuberger

@vbraun
Copy link
Member

vbraun commented Jan 31, 2016

Changed branch from u/dkrenn/asy/speed-topo-iter to b2af8aa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants