﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25750	During makemigrations Options._expire_cache takes 30% of the time	Patryk Zawadzki	Patryk Zawadzki	"Here's the profiler output:

{{{
         215373161 function calls (214826612 primitive calls) in 282.839 seconds

   Ordered by: internal time
   List reduced from 6484 to 10 due to restriction <10>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  5225318   59.334    0.000   89.667    0.000 django/db/models/options.py:711(_expire_cache)
 40538898   27.751    0.000   27.751    0.000 {delattr}
 16538241   18.624    0.000   38.450    0.000 django/apps/config.py:164(get_models)
   485536   16.907    0.000   27.126    0.000 django/db/models/fields/__init__.py:358(deconstruct)
  4466221   12.337    0.000   20.062    0.000 /usr/lib64/python2.7/collections.py:109(values)
    79811   10.893    0.000   53.060    0.001 django/apps/registry.py:153(get_models)
    73250   10.582    0.000   43.745    0.001 django/db/models/fields/related.py:317(swappable_setting)
   495362    8.314    0.000   11.430    0.000 django/db/models/fields/__init__.py:137(__init__)
 24359432    7.790    0.000    7.790    0.000 /usr/lib64/python2.7/collections.py:78(__iter__)
15623269/15397100    7.142    0.000    7.330    0.000 {getattr}
}}}

I have a pull request ready that makes it slightly better:

{{{
         164872486 function calls (164325937 primitive calls) in 199.897 seconds

   Ordered by: internal time
   List reduced from 6484 to 10 due to restriction <10>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 16538241   18.580    0.000   38.545    0.000 django/apps/config.py:164(get_models)
   485536   16.290    0.000   26.736    0.000 django/db/models/fields/__init__.py:358(deconstruct)
  4466221   12.357    0.000   20.069    0.000 /usr/lib64/python2.7/collections.py:109(values)
    79811   10.933    0.000   53.182    0.001 django/apps/registry.py:153(get_models)
    73250   10.694    0.000   43.931    0.001 django/db/models/fields/related.py:317(swappable_setting)
  5225318    9.295    0.000    9.406    0.000 django/db/models/options.py:711(_expire_cache)
   495362    8.807    0.000   11.958    0.000 django/db/models/fields/__init__.py:137(__init__)
 24359432    7.777    0.000    7.777    0.000 /usr/lib64/python2.7/collections.py:78(__iter__)
15623269/15397100    7.316    0.000    7.504    0.000 {getattr}
        2    4.863    2.431    4.863    2.431 {raw_input}
}}}"	Cleanup/optimization	closed	Migrations	1.8	Normal	fixed			Ready for checkin	1	0	0	0	0	0
