Merge lp:~sinzui/launchpad/timeout-portlet-package-summary-2 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Brad Crittenden
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~sinzui/launchpad/timeout-portlet-package-summary-2
Merge into: lp:launchpad
Diff against target: 86 lines (+14/-19)
3 files modified
lib/lp/registry/browser/distroseries.py (+6/-9)
lib/lp/registry/stories/distroseries/xx-distroseries-index.txt (+6/-6)
lib/lp/registry/templates/distroseries-portlet-packaging.pt (+2/-4)
To merge this branch: bzr merge lp:~sinzui/launchpad/timeout-portlet-package-summary-2
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+20228@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

This is my branch to guarantee that the distroseries page does not
timeout.

    lp:~sinzui/launchpad/timeout-portlet-package-summary-2
    Diff size: 88
    Launchpad bug: https://bugs.launchpad.net/bugs/526583
    Test command: ./bin/test -vv -t xx-distroseries-index
    Pre-implementation: no one
    Target release: 10.02

Guarantee that the distroseries page does not timeout
-----------------------------------------------------

+portlet-package-summary still causes timeouts after SQL tuning. Take
drastic measures like removing content to avoid making SQL calls that
are to expensive.

Rules
-----

    * Remove the list of packages that most need linking.
    * Factor out calls to getPrioritizedUnlinkedSourcePackages() that
      are used by view.num_unlinked_packages. The number of packages
that
      need linking can be derived from the total source packages minus
      the number of linked packages.
      * /me thinks the number of packages that need linking as
calculated
        now is wrong. It is too high and anyone looking at the numbers
in
        the page can work that out. 16829 - 1498 = 15331, not 15414. I
        suspect the difference is unpublished packages in the series.

QA
--

    * Visit https://edge.launchpad.net/ubuntu/lucid
    * Reload the page 10 times and do not see a timeout.

Lint
----

Linting changed files:
  lib/lp/registry/browser/distroseries.py
  lib/lp/registry/stories/distroseries/xx-distroseries-index.txt
  lib/lp/registry/templates/distroseries-portlet-packaging.pt

Test
----

    * lib/lp/registry/stories/distroseries/xx-distroseries-index.txt
      * Updated the test to show that packages that most need linking
are
        not listed.
      * Update the test to show the insane -2 packages need linking.
This
        is caused by stale distroseries.sourcecounts in sampledata. I
        decided to not force the number to be sane so that anyone
looking
        at the page in dev will see a test explaining why the number is
        wrong.

Implementation
--------------

    * lib/lp/registry/browser/distroseries.py
      * Updated num_unlinked_packages to use the fast and logical way to
        learn the number: total source packages - number of packagings.
      * Inlined _unlinked_packages to the only method that needs to use
        the expensive query. The template does not call this method. We
will
        work on getPrioritizedUnlinkedSourcePackages after this release.
    * lib/lp/registry/templates/distroseries-portlet-packaging.pt
      * Removed the needs linking section to avoid calling
        getPrioritizedUnlinkedSourcePackages.

Revision history for this message
Brad Crittenden (bac) wrote :

The changes look good for this pass. I hope we intend to solve the query problem and restore the "needs linking" section. Should you open a bug and put in an XXX comment to that effect? It might be good to comment out the existing TAL with an XXX rather than deleting it outright. Your call as to the details.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/distroseries.py'
2--- lib/lp/registry/browser/distroseries.py 2010-02-20 23:35:12 +0000
3+++ lib/lp/registry/browser/distroseries.py 2010-02-26 19:30:38 +0000
4@@ -337,25 +337,22 @@
5 """The number of linked packagings for this distroseries."""
6 return len(self.context.packagings)
7
8- @cachedproperty
9- def _unlinked_packages(self):
10- """Get a prioritized list of unlinked source packages."""
11- return self.context.getPrioritizedUnlinkedSourcePackages()
12-
13 @property
14 def num_unlinked_packages(self):
15 """The number of unlinked packagings for this distroseries."""
16- return len(self._unlinked_packages)
17+ return self.context.sourcecount - self.num_linked_packages
18
19 @cachedproperty
20 def recently_linked(self):
21 """Return the packages that were most recently linked upstream."""
22 return self.context.getMostRecentlyLinkedPackagings()
23
24- @property
25+ @cachedproperty
26 def needs_linking(self):
27- """Return a list of 10 packages most in need of upstream linking."""
28- return self._unlinked_packages[:10]
29+ """Return a list of 10 packages most in need of upstream linking."""
30+ # XXX sinzui 2010-02-26 bug=528648: This method causes a timeout.
31+ # return self.context.getPrioritizedUnlinkedSourcePackages()[:10]
32+ return None
33
34 milestone_can_release = False
35
36
37=== modified file 'lib/lp/registry/stories/distroseries/xx-distroseries-index.txt'
38--- lib/lp/registry/stories/distroseries/xx-distroseries-index.txt 2010-02-19 20:19:28 +0000
39+++ lib/lp/registry/stories/distroseries/xx-distroseries-index.txt 2010-02-26 19:30:38 +0000
40@@ -86,18 +86,18 @@
41 The distroseries page contains a portlet with information on the
42 upstream packaging.
43
44+ >>> # Note that warty's sourcecount is stale in sample data
45+ >>> # which causes -2 need linking.
46 >>> anon_browser.open('http://launchpad.dev/ubuntu/warty')
47 >>> print extract_text(
48- ... find_portlet(anon_browser.contents, 'Upstream packaging'))
49+ ... find_tag_by_id(anon_browser.contents, 'series-packaging'))
50 Upstream packaging
51 5 source packages are linked to registered upstream projects.
52- 3 need linking.
53+ -2 need linking.
54 Recently linked to upstream:
55 alsa-utils linked...
56 a52dec linked...
57 evolution linked...
58 mozilla-firefox linked...
59- netapplet linked...
60- Needs more information or linking to upstream:
61- linux-source-2.6.15 cdrkit iceweasel
62- Needs upstream links All upstream links
63+ netapplet linked 2005-07-05
64+ Needs upstream links All upstream links
65
66=== modified file 'lib/lp/registry/templates/distroseries-portlet-packaging.pt'
67--- lib/lp/registry/templates/distroseries-portlet-packaging.pt 2010-02-19 20:19:28 +0000
68+++ lib/lp/registry/templates/distroseries-portlet-packaging.pt 2010-02-26 19:30:38 +0000
69@@ -53,15 +53,13 @@
70 tal:condition="view/needs_linking">
71 Needs more information or linking to upstream:
72 </dt>
73- <dd>
74+ <dd tal:condition="view/needs_linking">
75 <ul class="horizontal">
76- <tal:package repeat="package view/needs_linking">
77- <li>
78+ <li repeat="package view/needs_linking">
79 <a class="sprite package-source"
80 tal:attributes="href package/package/fmt:url"
81 tal:content="package/package/name">evolution</a>
82 </li>
83- </tal:package>
84 </ul>
85 </dd>
86 </dl>