When `apps.ready` is `False`, the cache of model meta options is not
cleared. This speeds up the initial rendering of the test suite
significantly. The cache can then be cleared manually when all models are
rendered, and `apps.ready` can be set back to`True`.
Results timing `django.test.runner.DiscoverRunner.setup_databases`:
{{{
apps.ready == True - 42 seconds
apps.ready == False - 16 seconds
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24397>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: knbk (added)
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"888c9b6429a44824078a49fb1ebacf2e950cd887"]:
{{{
#!CommitTicketReference repository=""
revision="888c9b6429a44824078a49fb1ebacf2e950cd887"
Fixed #24397 -- Sped up rendering multiple model states.
Set apps.ready to False when rendering multiple models. This prevents
that the cache on Model._meta is expired on all models after each time a
single model is rendered. Prevented that Apps.clear_cache() refills the
cache on Apps.get_models(), so that the wrong value cannot be cached
when cloning a StateApps.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:3>
Comment (by knbk):
Additional PR: https://github.com/django/django/pull/4458
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:4>
* status: closed => new
* resolution: fixed =>
Comment:
Reopen due to further improvements.
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:5>
* needs_better_patch: 0 => 1
Comment:
Left some mostly cosmetic comments. Please advance to "Ready for Checkin"
after updating.
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:6>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
Comment:
I'm not too sure what the error message should be changed to, so I'll
leave it as is.
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"039d7881b441c6b358a963d652ffa2eada3a8892" 039d7881]:
{{{
#!CommitTicketReference repository=""
revision="039d7881b441c6b358a963d652ffa2eada3a8892"
Refs #24397 -- Sped up model reloading in ProjectState.
Created bulk_update() context manager on StateApps. Sped up unregistering
models in reload_models() by using this context mananger.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:8>
* status: new => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/24397#comment:9>