Django tests appear to be getting substantially slower

25 views
Skip to first unread message

Mark Jones

unread,
Jun 15, 2019, 11:26:35 AM6/15/19
to Django users
I was fixing up a Django app https://github.com/mark0978/django-softdelete and setting up tox to make sure it worked with all the listed versions because of issues opened on the original repo.  While I was running tox locally I noticed that with every version of Django, the tests ran slower, and from 1.8 -> 2.2 the test time was nearly doubled.  This was true for every version of python tested from 2.7 - 3.7.

If you want to check this on your machine, just grab the repo and run tox.  I'm including the minimal tox output to show this phenomenon.

py27-A installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,Django==1.8.19,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.821s

py27-B installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,Django==1.9.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.036s

py27-C installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,Django==1.10.8,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.198s

py27-D installed: DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.,Django==1.11.21,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 3.609s

py34-A installed: DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).,Django==1.8.19,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.733s

py34-B installed: DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).,Django==1.9.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.066s

py34-C installed: DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).,Django==1.10.8,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.232s

py34-D installed: DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).,Django==1.11.21,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 3.564s

py34-E installed: DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).,Django==2.0.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.515s

py35-A installed: Django==1.8.19,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.603s

py35-B installed: Django==1.9.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.923s

py35-C installed: Django==1.10.8,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.099s

py35-D installed: Django==1.11.21,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 3.252s

py35-E installed: Django==2.0.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.163s

py35-F installed: Django==2.1.9,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.784s

py35-G installed: Django==2.2.2,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1,sqlparse==0.3.0
----------------------------------------------------------------------
Ran 14 tests in 6.744s

py36-A installed: Django==1.8.19,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.619s

py36-B installed: Django==1.9.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.835s

py36-C installed: Django==1.10.8,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 3.025s

py36-D installed: Django==1.11.21,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 3.147s

py36-E installed: Django==2.0.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.058s

py36-F installed: Django==2.1.9,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.722s

py36-G installed: Django==2.2.2,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1,sqlparse==0.3.0
----------------------------------------------------------------------
Ran 14 tests in 6.524s

py37-A installed: Django==1.8.19,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.584s

py37-B installed: Django==1.9.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.730s

py37-C installed: Django==1.10.8,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 2.892s

py37-D installed: Django==1.11.21,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 3.050s

py37-E installed: Django==2.0.13,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.117s

py37-F installed: Django==2.1.9,-e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete,pytz==2019.1
----------------------------------------------------------------------
Ran 14 tests in 5.778s

py37-G installed: -e git...@github.com:mark0978/django-softdelete.git@72b46b0a7823a4fdcb43489663e90713ca7d698d#egg=django_softdelete
----------------------------------------------------------------------
Ran 14 tests in 6.647s

Simon Charette

unread,
Jun 15, 2019, 12:19:18 PM6/15/19
to Django users
Hi Mark,

It's hard to tell exactly what's going on without more details but assuming you are running tests
against SQLite the 2.1 to 2.2 slowdown is likely caused by the fact database constraints are
now checked of each TestCase[0].

Cheers,
Simon

Mark Jones

unread,
Jun 15, 2019, 12:32:56 PM6/15/19
to django...@googlegroups.com
Maybe that's the case, I didn't build the python2.7 or 3.7, but I used pyenv to install 3.4, 3.5, and 3.6 and they are all using the same version of SQLite.  And with each version of python, the tests slow down as the version of django increases.  Could this still be the SQLite v2.1->v2.2?

Django isn't getting slower as the version of python increases, it's getting slower as the version of Django increases.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/XQit6Kf4ZRA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/84e45bad-87d0-4da0-acd9-26e00140b05a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Charette

unread,
Jun 15, 2019, 1:15:01 PM6/15/19
to Django users
I meant Django 2.0 -> 2.1. As long as you are using Django 2.2 with SQLite 3.20+
the slowdown I mentioned should be effective.

Simon

Le samedi 15 juin 2019 08:32:56 UTC-4, Mark Jones a écrit :
Maybe that's the case, I didn't build the python2.7 or 3.7, but I used pyenv to install 3.4, 3.5, and 3.6 and they are all using the same version of SQLite.  And with each version of python, the tests slow down as the version of django increases.  Could this still be the SQLite v2.1->v2.2?

Django isn't getting slower as the version of python increases, it's getting slower as the version of Django increases.

To unsubscribe from this group and all its topics, send an email to django...@googlegroups.com.

Mark Jones

unread,
Jun 15, 2019, 3:25:10 PM6/15/19
to django...@googlegroups.com
Ah, but the slowdown is happening from 1.8 forward, each version of Django make things just a bit slower.  It's a gradual slowdown.

I do think I've got 3.2x libsqlite though.  So we can account for the slowdown on 2.1 -> 2.2

/usr/lib/libsqlite3.0.dylib
/usr/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.dylib


To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Simon Charette

unread,
Jun 16, 2019, 11:53:59 PM6/16/19
to Django users
Again, it's hard to tell what the slowdown might be caused by without a more detailed
investigation. I suggest you use cProfile[0] for that.

Given your tests are only running for a small amount of time relative to Django's setup
time I assume two things are causing the apparent slowdown:

1. A slower Django setup(), I think some changes were part of 1.8 -> 1.11
2. Reliance on now lazily loaded part of Django.

Cheers,
Simon


Le samedi 15 juin 2019 11:25:10 UTC-4, Mark Jones a écrit :
Ah, but the slowdown is happening from 1.8 forward, each version of Django make things just a bit slower.  It's a gradual slowdown.

I do think I've got 3.2x libsqlite though.  So we can account for the slowdown on 2.1 -> 2.2

/usr/lib/libsqlite3.0.dylib
/usr/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.27.1/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.28.0/lib/libsqlite3.dylib


Reply all
Reply to author
Forward
0 new messages