#27279: Slow test framework initialization in 1.10.1 compared to 1.10
-------------------------------------+-------------------------------------
Reporter: mtomiyoshi | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Migrations | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
The final state has to be rendered to allow `post_migrate` to dispatch its
`apps` argument even when `--keepdb` is used.
The issue here is that during the process of computing the final state
some operation's `state_forwards` might require access to `state.apps`
triggering the rendering. I know that Markus has been working on teaching
the migration framework to ''forward'' without accessing rendered model
state but in this case we might be able to get away by preventing
`reload_model()` from actually doing anything by deleting `state.apps`
[https://github.com/django/django/commit/d5c4ea524679a787fe11c927448e44e95646096b
#diff-191c6b8087fd8fb2cc08a2d9f9bf44deR79 on every step] of `mutate_state`
as `reload_model()` is a noop when `state.apps`
[https://github.com/django/django/blob/master/django/db/migrations/state.py#L104
is missing].
The `RenameModel.state_forwards()` operation still require access to
`state.apps` (that should be fixed if possible in 1.11) so migrations
containing them would still trigger an extra model rendering but the
subsequent call to `render_model()` wouldn't until another `RenameModel`
operation is performed.
TL;DR adding a `delattr(state, 'apps', None)` before `mutate_state()`
[https://github.com/django/django/commit/d5c4ea524679a787fe11c927448e44e95646096b
#diff-191c6b8087fd8fb2cc08a2d9f9bf44deR81 here] should speed up things
significantly.
--
Ticket URL: <https://code.djangoproject.com/ticket/27279#comment:3>
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/068.f2975709ff8c451b5a71077d638c5ed6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.