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

10x Slowdown in series with sqrt #19530

Closed
oscarbenjamin opened this issue Jun 11, 2020 · 5 comments
Closed

10x Slowdown in series with sqrt #19530

oscarbenjamin opened this issue Jun 11, 2020 · 5 comments

Comments

@oscarbenjamin
Copy link
Contributor

There is a significant slowdown in

sympy/core/tests/test_power.py::test_issue_6068

I've bisected that to commit 8a06c07 in this #19369.

The content of the test is

from sympy import *

x = Symbol('x')
assert sqrt(sin(x)).series(x, 0, 7) == \
    sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - \
    x**Rational(13, 2)/24192 + O(x**7)
assert sqrt(sin(x)).series(x, 0, 9) == \
    sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - \
    x**Rational(13, 2)/24192 - 67*x**Rational(17, 2)/29030400 + O(x**9)
assert sqrt(sin(x**3)).series(x, 0, 19) == \
    x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 + O(x**19)
assert sqrt(sin(x**3)).series(x, 0, 20) == \
    x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 - \
    x**Rational(39, 2)/24192 + O(x**20)

In sympy 1.6 that takes 5 seconds whereas on master it takes 45 seconds.

Originally posted by @oscarbenjamin in #19369 (comment)

@oscarbenjamin
Copy link
Contributor Author

CC @sachin-4099

@oscarbenjamin
Copy link
Contributor Author

I've been wondering whether the test script should fail if a test becomes unexpectedly slow. I was thinking that we could require all not slow tests to run in under 10 seconds and fail the tests if any exceeds 20 seconds which would have picked this up.

@sachin-4099
Copy link
Contributor

This is not happening on my master:

In [8]:  %time assert sqrt(sin(x)).series(x, 0, 7) == sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - x**Rational(13, 2)/24192 + O(x**7)
Wall time: 234 ms

In [9]: %time assert sqrt(sin(x)).series(x, 0, 9) == sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - x**Rational(13, 2)/24192 - 67*x**Rational(17, 2)/29030400 + O(x**9)
Wall time: 203 ms

In [10]: %time assert sqrt(sin(x**3)).series(x, 0, 19) == x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 + O(x**19)
Wall time: 223 ms

In [11]: %time assert sqrt(sin(x**3)).series(x, 0, 20) == x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 - x**Rational(39, 2)/24192 + O(x**20)
Wall time: 218 ms

Is this related to a specific version of python?

@jksuom
Copy link
Member

jksuom commented Jun 11, 2020

This is what I get:

In [11]: from sympy.core.tests.test_power import *

In [12]: %time test_issue_6068()
CPU times: user 1.19 s, sys: 0 ns, total: 1.19 s
Wall time: 1.19 s

@oscarbenjamin
Copy link
Contributor Author

I just updated my master and it finishes in 1.5 seconds now. I'm not sure how to reproduce this any more...

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