person:+activereviews times out

Bug #867941 reported by Martin Pool
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Raphaël Badin

Bug Description

despite bug 826692 being fixed (and it did improve things), https://code.launchpad.net/~ubuntu-branches/+activereviews still times out quite frequently, though not on every request.

Related branches

Revision history for this message
Raphaël Badin (rvb) wrote :

I can see two areas that can be improved here:
a) this page issues a huge query (4.5s)
and
b) 1000+ small queries.

Changed in launchpad:
assignee: nobody → Raphaël Badin (rvb)
status: Triaged → In Progress
Revision history for this message
Raphaël Badin (rvb) wrote :

a) tried using CTE to see if the query could be improved inplace but no luck so far (https://pastebin.canonical.com/55779/, https://pastebin.canonical.com/55780/).

Revision history for this message
Raphaël Badin (rvb) wrote :

b) this can probably be improved by caching related objects up front.

Revision history for this message
Raphaël Badin (rvb) wrote :
Revision history for this message
Raphaël Badin (rvb) wrote :

jtv found that using a temporary table with an index in lieu et place of the CTE improves things quite significantly:
https://pastebin.canonical.com/55838/. The temp tables takes ~1s to setup and the main query now takes ~200ms (https://pastebin.canonical.com/55836/).

This is pretty amazing but it means that we would have to use the master store to be able to create the temporary table.

Revision history for this message
Raphaël Badin (rvb) wrote :

It seems that my run of the CTE version was simply unlucky (locking…). a new run of the exact same query by stub show that it improves things significantly: https://pastebin.canonical.com/55946/.

Revision history for this message
Raphaël Badin (rvb) wrote :

I will also see if it's possible/easy to avoid materializing the big list of all public and private-but-visable branches.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 867941] Re: +activereviews times out

FWIW: you don't need the master store to use temp tables.

Revision history for this message
Raphaël Badin (rvb) wrote : Re: +activereviews times out

Right, stub also said so this morning too.

I've a branch ready that refactors ./lib/lp/code/model/branchcollection.py a little to issue a CTE version.

Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Revision history for this message
Raphaël Badin (rvb) wrote :

Looks like eager loading related objects did good (number of queries has been / 2) but there is still room for improvement.

Raphaël Badin (rvb)
tags: added: qa-ok
removed: qa-needstesting
Raphaël Badin (rvb)
summary: - +activereviews times out
+ person:+activereviews times out
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
removed: qa-ok
Changed in launchpad:
status: In Progress → Fix Committed
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Raphaël Badin (rvb)
tags: added: qa-bad
removed: qa-needstesting
Revision history for this message
Raphaël Badin (rvb) wrote :

I've reverted the changes made by: https://code.launchpad.net/~rvb/launchpad/activereviews-bug-867941-hugequery

r14374 is the rollback to r14355.

Raphaël Badin (rvb)
tags: added: qa-ok
removed: qa-bad
Revision history for this message
Raphaël Badin (rvb) wrote :

Only one repeated statement is left: the one to get the chain of stacked_on branches. This is a tricky one because the information here is recursive but we should be able to prefetch that data too.

Raphaël Badin (rvb)
Changed in launchpad:
status: Fix Committed → In Progress
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
removed: qa-ok
Changed in launchpad:
status: In Progress → Fix Committed
Revision history for this message
Raphaël Badin (rvb) wrote :

Total number of queries is down to 46 (qastaging). Marking this as qa-ok.

tags: added: qa-ok
removed: qa-needstesting
Revision history for this message
William Grant (wgrant) wrote :

Timed out the first time with OOPS-b8497e045278f93da7c4acce455fdf47, but succeeded with 46 queries/external actions issued in 6.00 seconds a second time.

Changed in launchpad:
status: Fix Committed → Fix Released
Revision history for this message
Raphaël Badin (rvb) wrote :

@wgrant: this is really weird because the oops you pasted has some repeated statements (SourcePackageName) that I know for a fact are pre-fetched now.

Revision history for this message
William Grant (wgrant) wrote :

Ah, looking at the OOPS, I must have hit the appservers when not all of them were updated. It is from the old revno, so nevermind.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.