#24743: Django 1.8.1 migrations are actually slower than 1.8?
--------------------------------------+------------------------------------
Reporter: pzrq | Owner: MarkusH
Type: Cleanup/optimization | Status: assigned
Component: Migrations | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by MarkusH):
I thought about giving the rendering another improvement, but before
diving in I ran cProfile on the `rendering model states` phase on the
current stable/1.8.x branch (0e3a8c22dfbbe06a9a81afb2593255293efdc87e) and
master (97ac77e544f9b1d1f28c0f859bef8fbc195d81a5) with the following diff
applied:
{{{#!diff
diff --git a/django/core/management/commands/migrate.py
b/django/core/management/commands/migrate.py
index d26fd3d..40dca0b 100644
--- a/django/core/management/commands/migrate.py
+++ b/django/core/management/commands/migrate.py
@@ -219,7 +219,9 @@ class Command(BaseCommand):
else:
fake = options.get("fake")
fake_initial = options.get("fake_initial")
- executor.migrate(targets, plan, fake=fake,
fake_initial=fake_initial)
+ import cProfile
+ cProfile.runctx('executor.migrate(targets, plan, fake=fake,
fake_initial=fake_initial)', globals(), locals(),
filename='/tmp/stats.pstats')
+ # executor.migrate(targets, plan, fake=fake,
fake_initial=fake_initial)
# Send the post_migrate signal, so individual apps can do
whatever they need
# to do at this point.
diff --git a/django/db/migrations/executor.py
b/django/db/migrations/executor.py
index aeb021e..2c08ab3 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -104,6 +104,7 @@ class MigrationExecutor(object):
state = migration.mutate_state(state, preserve=do_run)
if self.progress_callback:
self.progress_callback("render_success")
+ return
# Phase 2 -- Run the migrations
for migration, backwards in plan:
if not backwards:
}}}
This yield the attached pstats files with my "benchmark" repository
https://github.com/MarkusH/django-migrations-benchmark. I put the output
of the first ~40 rows into a gist (better readability):
https://gist.github.com/MarkusH/0c5d30449cdf7f1961f6 . What one can see is
a reduction by almost 50%.
Can somebody confirm this improvement in one of their real world projects,
please.
This is on Python 3.4.3 on ArchLinux
--
Ticket URL: <https://code.djangoproject.com/ticket/24743#comment:17>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/062.5ce2819033907cd7ed04e2b002cedfd3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.