Opened 2 years ago

Closed 2 years ago

#33848 closed Cleanup/optimization (fixed)

Migration StateApps.clone deepcopy too many objects

Reported by: Iuri de Silvio Owned by: Iuri de Silvio
Component: Migrations Version: 4.0
Severity: Normal Keywords:
Cc: Simon Charette Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Iuri de Silvio)

StateApps.clone execute two slow deep copies. The first one copy all models. The second one copy app configs, that include all apps and the specific app models.

In my application, with ~250 models, this deepcopy is around 5% of migration time. I was able to cleanup StateApps before copy, to not copy all models and apps every operation again. After the optimization, it takes less than 1% of migration time.

https://github.com/django/django/blob/d4c5d2b52c897ccc07f04482d3f42f976a79223c/django/db/migrations/state.py#L683

Change History (4)

comment:1 by Iuri de Silvio, 2 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 2 years ago

Cc: Simon Charette added
Owner: changed from nobody to Iuri de Silvio
Status: newassigned
Triage Stage: UnreviewedAccepted

Thanks!

comment:3 by Mariusz Felisiak, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In f0fa2a3b:

Fixed #33848 -- Optimized StateApps.clone().

Note: See TracTickets for help on using tickets.
Back to Top