Opened 9 years ago
Closed 9 years ago
#25805 closed Cleanup/optimization (needsinfo)
Django 1.8 startup takes longer than Django 1.7
Reported by: | Filipe Pina | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi, this is less of a bug and more of a RFI..
I've recently noticed on a django (1.8.6) project I run in a Raspberry Pi (model B+) that manage.py always takes more than 20secs to import all modules. I assumed it was due to RPi poor performance but then I noticed on a different project (that uses django 1.7.x) that it took less than 7 secs to do the same.
Steps to reproduce (and compare):
[fopina@izdoors test2]$ virtualenv2 env New python executable in env/bin/python2 Also creating executable in env/bin/python Installing setuptools, pip, wheel...done. [fopina@izdoors test2]$ . env/bin/activate (env)[fopina@izdoors test2]$ pip install Django Collecting Django Using cached Django-1.8.6-py2.py3-none-any.whl Installing collected packages: Django Successfully installed Django-1.8.6 (env)[fopina@izdoors test2]$ django-admin startproject t18 (env)[fopina@izdoors test2]$ cd t18/ (env)[fopina@izdoors t18]$ time (echo 1 | python manage.py shell) Python 2.7.10 (default, Sep 17 2015, 19:25:26) [GCC 5.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> 1 >>> real 0m23.555s user 0m22.810s sys 0m0.480s
And with 1.7.10, on the same Pi:
[fopina@izdoors test]$ virtualenv2 env New python executable in env/bin/python2 Also creating executable in env/bin/python Installing setuptools, pip, wheel...done. [fopina@izdoors test]$ . env/bin/activate (env)[fopina@izdoors test]$ pip install Django==1.7.10 Collecting Django==1.7.10 Downloading Django-1.7.10-py2.py3-none-any.whl (7.4MB) 100% |################################| 7.4MB 3.2kB/s Installing collected packages: Django Successfully installed Django-1.7.10 (env)[fopina@izdoors test]$ django-admin startproject t17 (env)[fopina@izdoors test]$ cd t17/ (env)[fopina@izdoors t17]$ time (echo 1 | python manage.py shell) Python 2.7.10 (default, Sep 17 2015, 19:25:26) [GCC 5.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> 1 >>> real 0m7.689s user 0m6.340s sys 0m0.400s
I've tried going through the imports done in 1.8 to see if there was anything I could do to improve its time but I failed to identify the guilty ones...
I've downgraded my application to django 1.7 because it has a lot of management commands and I had no impact, but I was wondering if it's a known fact that 1.8 has a lot more (or heavier) imports than 1.7..
Thanks
Change History (5)
comment:1 by , 9 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:2 by , 9 years ago
Summary: | Raspberry Pi 1.7 vs 1.8 performance → Django 1.8 startup takes longer than Django 1.7 |
---|
comment:3 by , 9 years ago
Also, did you try running the 1.8 test _after_ you ran the 1.7 test? The time difference could just be loading shared python code from the SD card into ram for the first time.
comment:4 by , 9 years ago
Perhaps Django 1.8 gained some checks which are expensive on this particular project?
You could test for that by running:
export DJANGO_SETTINGS_MODULE=yourproject.settings
time python -c "import django; django.setup()"
How long does that take on 1.7 and 1.8?
Try running it on 1.7, 1.8, 1.7, 1.8 for the reason Collin brought up.
comment:5 by , 9 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
No immediate ideas come to mind. Can you bisect to find the commit where the performance changed?