Code

#19276 closed Cleanup/optimization (fixed)

ORM performance regression between 1.4.x and 1.5.x

Reported by: akaariai Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5-alpha-1
Severity: Release blocker Keywords:
Cc: 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

I did some benchmarking for performance regressions between 1.4 and 1.5 (using Python 2.6.7 and djangobench). I found that nearly every ORM benchmark for djangobench has regressed about 10%. I made a time series of one benchmark (query_annotate), available here: http://users.tkk.fi/~akaariai/djbench/query_annotate.html

There are two commits which show up in the graph:

It seems there is some low-hanging fruit especially for the second commit, see here: https://github.com/akaariai/django/compare/orm_perf

Attachments (0)

Change History (7)

comment:1 Changed 18 months ago by akaariai

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

One more regression spotted - query_select_related got hit by the above regressions + another change made for fixing Oracle in select_related cases. Commit: c159d9cec0baab7bbd04d5d51a92a51e354a722a, graph here: http://users.tkk.fi/~akaariai/djbench/query_select_related/

A patch for the select_related case is available here: https://github.com/akaariai/django/compare/fix_select_related_perf (the reason for the regression was the repeated access to connections[using], the fix dodges this and makes the code a little cleaner, too).

I am elevating this to release blocker. While the regressions aren't really that severe, it is a good idea to check if we can easily fix the performance regressions before the final release. If not, then lets just close this ticket. So, release blocker as in "lets not forget to check this before release".

comment:2 Changed 18 months ago by akaariai

  • Triage Stage changed from Accepted to Ready for checkin

I did a little more work, and now I have RFC stuff in https://github.com/akaariai/django/compare/ticket_19276

comment:3 Changed 18 months ago by Anssi Kääriäinen <akaariai@…>

In fa18b0ac89723f4ed6e46e744039bf375c8945a5:

Some changes to SortedDict to make it faster under py2

Refs #19276

comment:4 Changed 18 months ago by Anssi Kääriäinen <akaariai@…>

In ce1af8d7023f02e4521cce3bcdbc9fd13d76c5f8:

Removed use of SortedDict for query.alias_refcount

This will have a smallish impact on performance. Refs #19276.

comment:5 Changed 18 months ago by Anssi Kääriäinen <akaariai@…>

In 538d6c0fcd7e0a5505aa4d0424edc823ce2f511f:

Some changes to SortedDict to make it faster under py2

Refs #19276

comment:6 Changed 18 months ago by Anssi Kääriäinen <akaariai@…>

In fe21c233d44a5cafff0766eb17ed3df20e08b70f:

Removed use of SortedDict for query.alias_refcount

This will have a smallish impact on performance. Refs #19276.

comment:7 Changed 18 months ago by akaariai

  • Resolution set to fixed
  • Status changed from new to closed

OK, it seems the regressions are now fixed, see: http://users.tkk.fi/~akaariai/djbench/query_select_related/ and http://users.tkk.fi/~akaariai/djbench/query_annotate/ (the last commits are barely visible in the right, but they are there...).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.