Re: [Django] #24554: Migrations taking up to an hour to run

2015-04-01 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:  fixed
 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 Markus Holtermann ):

 In [changeset:"0c7e2833d9b6f0bbd847d9b9b0eb368611425f7c" 0c7e283]:
 {{{
 #!CommitTicketReference repository=""
 revision="0c7e2833d9b6f0bbd847d9b9b0eb368611425f7c"
 [1.8.x] Fixed #24554 -- Sped up migrations by rendering initial apps when
 they are first needed

 Calling Migration.mutate_state() now also allows to do in_place
 mutations in case an intermediate state is thrown away later.

 Thanks Anssi Kääriäinen for the idea, Ryan Hall for parts of the patch,
 and Claude Paroz and Tim Graham for the review

 Backport of 57dc8dd3fa3c3adf133c522ecadb501d94bacd52 from master
 }}}

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.69fc1c19fca4a6f41c05a3cc849715e6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-04-01 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:  fixed
 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 Markus Holtermann ):

 In [changeset:"2218f7617e6192a706bf7792db34b034765263e2" 2218f761]:
 {{{
 #!CommitTicketReference repository=""
 revision="2218f7617e6192a706bf7792db34b034765263e2"
 [1.8.x] Refs #24554 -- Prevented rendering of unused migrations

 Thanks Claude Paroz and Tim Graham for the review

 Backport of 3e7d9d05ac5efff4e4732c3453c7a8ef502d0ed0 from master
 }}}

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.bbf85e596f3ecb2e959e7425031cd3d9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:  fixed
 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 Markus Holtermann ):

 In [changeset:"3e7d9d05ac5efff4e4732c3453c7a8ef502d0ed0" 3e7d9d05]:
 {{{
 #!CommitTicketReference repository=""
 revision="3e7d9d05ac5efff4e4732c3453c7a8ef502d0ed0"
 Refs #24554 -- Prevented rendering of unused migrations

 Thanks Claude Paroz and Tim Graham for the review
 }}}

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.38432d58bf36e53c3c48cf490645d513%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Markus Holtermann ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"57dc8dd3fa3c3adf133c522ecadb501d94bacd52" 57dc8dd3]:
 {{{
 #!CommitTicketReference repository=""
 revision="57dc8dd3fa3c3adf133c522ecadb501d94bacd52"
 Fixed #24554 -- Sped up migrations by rendering initial apps when they are
 first needed

 Calling Migration.mutate_state() now also allows to do in_place
 mutations in case an intermediate state is thrown away later.

 Thanks Anssi Kääriäinen for the idea, Ryan Hall for parts of the patch,
 and Claude Paroz and Tim Graham for the review
 }}}

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.c2b4bee8f921563b6410cf33e84339ca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 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 ryanahall):

 Actually @knbk, it looks like I've been profiling with that commit all
 along. I pulled master yesterday, so these results are fairly recent.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.5a639502fb1916b55fa9e17d2ff15821%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 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 ryanahall):

 @knbk thanks for pointing out that change, I'll pull it and give it a
 shot. I also just commented on my pr, but for the sake of consistency I'll
 put it here as well.

 Thanks for the quick response @MarkusH, I just pulled that pr's branch and
 tested it out - looks good to me! Here's the output from cProfile this
 time around:

 {{{
 10.0010.001 1047.865 1047.865 manage.py:2()
 10.0000.000 1047.800 1047.800
 /django/core/management/__init__.py:325(execute_from_command_line)
 10.0000.000 1047.800 1047.800
 /django/core/management/__init__.py:265(execute)
 10.0000.000 1040.621 1040.621
 /django/core/management/base.py:326(run_from_argv)
 10.0020.002 1040.619 1040.619
 /django/core/management/base.py:361(execute)
 10.1740.174 1039.459 1039.459
 /django/core/management/commands/migrate.py:50(handle)
 10.0840.084 1036.643 1036.643
 /django/db/migrations/executor.py:65(migrate)
  38510.3290.000  958.3410.249
 /django/db/migrations/state.py:87(reload_model)
   8000.0140.000  953.8131.192
 /django/db/migrations/migration.py:72(mutate_state)
  31530.1780.000  455.8060.145
 /django/db/migrations/state.py:230(render_multiple)
133631   31.2200.000  438.5940.003
 /django/apps/registry.py:323(clear_cache)
 567022.2740.000  425.4920.008
 /django/db/migrations/state.py:505(render)
  17450.0210.000  420.8440.241
 /django/db/migrations/operations/fields.py:43(state_forwards)
 626400.2810.000  407.2270.007
 /django/db/migrations/state.py:279(unregister_model)
  11660.0310.000  402.4080.345
 /django/db/migrations/operations/fields.py:172(state_forwards)
   13580756.3340.000  383.4270.000
 /django/db/migrations/state.py:474(construct_fields)
  30963570  233.7180.000  347.2630.000
 /django/db/models/options.py:712(_expire_cache)
139593  116.2180.001  253.9010.002
 /django/db/models/fields/related.py:297(swappable_setting)
1276280.6810.000  238.1170.002
 /django/db/models/fields/related.py:1927(deconstruct)
1276281.1650.000  237.2040.002
 /django/db/models/fields/related.py:1635(deconstruct)
 }}}

 For reference, most of the time was spent while rendering the states which
 was expected.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.ef62e584964b5484f72caf5926659a95%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 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
-+-
Changes (by knbk):

 * version:  1.7 => master
 * stage:  Unreviewed => Accepted


Comment:

 At first glance this looks like an effective and safe way to speed up
 migrations.

 Could you also check how 888c9b6429a44824078a49fb1ebacf2e950cd887 affects
 the migration time on your project? I'm quite curious how much of a
 difference that will make.

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.0da34d6f7537c685ce0866dff4b076b0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-31 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  master
 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):

 Hey Ryan, thanks for reporting the issue. Would you mind checking our
 https://github.com/django/django/pull/4151 . Besides the change you made
 above (except for the part where you touch the graph) it also incorporates
 some further speedups. Maybe we can squeeze it in 1.8

--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2dd931e378b956d8f70d9dd83ef56bb1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-30 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  ryanahall
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Migrations   |  Version:  1.7
 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
-+-
Changes (by ryanahall):

 * status:  new => assigned
 * owner:  nobody => ryanahall


--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.feffe3775633a3ad9abe860ef1be33a3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24554: Migrations taking up to an hour to run

2015-03-30 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Migrations   |  Version:  1.7
 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
-+-
Description changed by ryanahall:

Old description:

> We're currently running django 1.7.2 and been having performance issues
> with migrate/makemigrations for the last few months now, but until
> recently it hasn't caused us too much trouble. Recently,
> migrate/makemigrations calls have reached a point where they take up to
> 45minutes to run. Unfortunately, this is due to the fact that we have
> around 700 models defined with almost 850 migrations since the initial
> project. Regardless, I've been looking for any ways to speed this process
> up in 1.7.2/1.7.7/1.8b2/master and found that we have a significant
> bottleneck with the way states are cloned.
>
> Out of curiousity, I profiled latest master against a set of ~7
> migrations to run and found this:
> {{{
>ncalls  tottime  percall  cumtime  percall filename:lineno(function)
> 10.0010.001 2687.730 2687.730 manage.py:2()
> 10.0000.000 2687.669 2687.669
> django/core/management/__init__.py:325(execute_from_command_line)
> 10.0000.000 2687.669 2687.669
> django/core/management/__init__.py:265(execute)
> 10.0000.000 2680.113 2680.113
> django/core/management/base.py:326(run_from_argv)
> 10.0020.002 2680.111 2680.111
> django/core/management/base.py:361(execute)
> 10.1980.198 2678.912 2678.912
> django/core/management/commands/migrate.py:50(handle)
> 1   10.405   10.405 2676.084 2676.084
> django/db/migrations/executor.py:65(migrate)
>   8030.0240.000 2581.3363.215
> django/db/migrations/migration.py:72(mutate_state)
>   7528892   36.4220.000 1578.0580.000
> django/db/migrations/state.py:468(construct_fields)
>  41370.5040.000 1470.0270.355
> django/db/migrations/state.py:81(reload_model)
>   8470.0120.000 1192.5851.408
> django/db/migrations/state.py:135(clone)
>   8470.9390.001 1171.2241.383
> django/db/migrations/state.py:138()
>4029486.2380.000 1170.2850.003
> django/db/migrations/state.py:488(clone)
> }}}
>
> In migration.py(mutate_state), the project state gets cloned before
> applying the operations everytime. I realize that the project state is
> intended to be immutable since the intermediary states need to be used
> most of the time, but I'm curious if it is required. During phase 1 of
> migration execution, the state gets cloned on every iteration inside
> mutate_state at line 90:
> {{{#!python
> for migration, _ in full_plan:
> if migration in migrations_to_run:
> states[migration] = state.clone()
> state = migration.mutate_state(state)  # state is cloned
> inside
> }}}
> and also in migrations/graph.py(make_state) at line 274:
> {{{#!python
> for node in plan:
> project_state = self.nodes[node].mutate_state(project_state)
> }}}
>
> If I modify mutate_state and add an option to not preserve (no clone) the
> passed in state in these specific cases, the migration time is cut in
> half:
> {{{
>ncalls  tottime  percall  cumtime  percall filename:lineno(function)
> 10.0010.001  955.337  955.337 manage.py:2()
> 10.0000.000  955.269  955.269
> django/core/management/__init__.py:325(execute_from_command_line)
> 10.0000.000  955.269  955.269
> django/core/management/__init__.py:265(execute)
> 10.0000.000  946.453  946.453
> django/core/management/base.py:326(run_from_argv)
> 10.0020.002  946.450  946.450
> django/core/management/base.py:361(execute)
> 10.1690.169  945.012  945.012
> django/core/management/commands/migrate.py:50(handle)
> 10.0060.006  941.582  941.582
> django/db/migrations/executor.py:65(migrate)
>  41370.3870.000  869.4330.210
> django/db/migrations/state.py:81(reload_model)
>   8030.0200.000  863.4341.075
> django/db/migrations/migration.py:72(mutate_state)
>100499   28.2330.000  405.0160.004
> django/apps/registry.py:323(clear_cache)
>  17530.0270.000  399.2870.228
> 

Re: [Django] #24554: Migrations taking up to an hour to run (was: Migrations taking close to an hour to run)

2015-03-30 Thread Django
#24554: Migrations taking up to an hour to run
-+-
 Reporter:  ryanahall|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Migrations   |  Version:  1.7
 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
-+-
Changes (by ryanahall):

 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * needs_tests:   => 0


--
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.f8337f28a29734b57c1124039c1e5d1f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.