Merge lp:~sinzui/launchpad/registry-tales-2 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Merged at revision: 11077
Proposed branch: lp:~sinzui/launchpad/registry-tales-2
Merge into: lp:launchpad
Diff against target: 97 lines (+22/-9)
4 files modified
lib/lp/registry/browser/tests/milestone-views.txt (+15/-4)
lib/lp/registry/templates/distroseries-needs-packaging.pt (+2/-1)
lib/lp/registry/templates/distroseries-packaging.pt (+2/-1)
lib/lp/registry/templates/milestone-index.pt (+3/-3)
To merge this branch: bzr merge lp:~sinzui/launchpad/registry-tales-2
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Review via email: mp+28760@code.launchpad.net

Description of the change

This is my branch to adjust the cache rules for registry pages.

    lp:~sinzui/launchpad/registry-tales-2
    Diff size:
    Launchpad bug:
          https://bugs.launchpad.net/bugs/599614
          https://bugs.launchpad.net/bugs/599818
    Test command: ./bin/test -vv \
          -t milestone-views -t packaging-views \
          -t xx-sourcepackage-packaging -t xx-show-distroseries-packaging
    Pre-implementation: no one
    Target release: 10.06

Adjust the cache rules for registry pages
-----------------------------------------

Bug #599614 [bad caching in milestone page]
    "Assigned to you" <- the data is user-specific, pubic, not private

Bug #599818 [distroseries +packaging and +needs-packaging could cache]
    Recent schema changes make data retrieval for +packaging and +needs-
    packaging much faster, but packages are added/removed from +packaging and
    +needs-packaging about 10 times a day. The queries rarely return *new*
    information. A 30 minute public cache will help the pages display quicker.

Rules
-----

Bug #599614 [bad caching in milestone page]
    * Use "private" cache so that the "Assigned to you" information is really
      about you.
    * Add a test for this since it is now understood that the information
      is personalised.

Bug #599818 [distroseries +packaging and +needs-packaging could cache]
    * Add tal:content="cache:public, 30 minute" to +packaging and
      +needs-packaging.

QA
--

Bug #599614 [bad caching in milestone page]
    * As anonymous, visit an old milestone that you know you were assigned
      bug.
    * Verify it states that no bugs or blueprints are assigned to you.
    * Login.
    * Verify the page states the number of bugs or blueprints assigned to you.

Bug #599818 [distroseries +packaging and +needs-packaging could cache]
    * Visit https://edge.launchpad.net/ubuntu/maverick/+needs-packaging
    * Load the page 5 times and verify it does not timeout once it renders
      (staging will probably not timeout because if the schema changes)
    * Visit https://edge.launchpad.net/ubuntu/maverick/+packaging
    * Load the page 5 times and verify it does not timeout once it renders

Lint
----

Linting changed files:
  lib/lp/registry/browser/tests/milestone-views.txt
  lib/lp/registry/templates/distroseries-needs-packaging.pt
  lib/lp/registry/templates/distroseries-packaging.pt
  lib/lp/registry/templates/milestone-index.pt

Test
----

    * lib/lp/registry/browser/tests/milestone-views.txt
      * Revised the test to work with only the content under test.
      * Added a test for the cache rules of the activity portlet.

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

    * lib/lp/registry/templates/distroseries-needs-packaging.pt
      * Added a 30 minute public cache.
    * lib/lp/registry/templates/distroseries-packaging.pt
      * Added a 30 minute public cache.
    * lib/lp/registry/templates/milestone-index.pt
      * Changed the cache rules from public to private.

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) :
review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

If I had fixed this I would have kept the overall project counts cached as public, and just made the assigned bugs count private. I don't have a good feel for whether the cost of recalculating them actually makes that worthwhile.

Revision history for this message
Curtis Hovey (sinzui) wrote :

The calculations appear to be very expensive because of the possibilities of private bugs. The loop that creates the info, while heavily cached and optimised to make minimal passes through the list often appears in timeouts. Bug privacy truly sucks. I prefer to cache the whole thing because I would like to go one month without complaints of timeouts.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/tests/milestone-views.txt'
2--- lib/lp/registry/browser/tests/milestone-views.txt 2010-06-24 17:59:02 +0000
3+++ lib/lp/registry/browser/tests/milestone-views.txt 2010-06-29 15:10:49 +0000
4@@ -248,7 +248,7 @@
5 the product release data for a milestone.
6
7 >>> from canonical.launchpad.testing.pages import (
8- ... extract_text, find_tag_by_id)
9+ ... extract_text, find_main_content, find_tag_by_id)
10
11 >>> view = create_view(
12 ... milestone, '+productrelease-data', principal=person)
13@@ -307,6 +307,7 @@
14 Active milestones cache bugtasks for 10 minutes.
15
16 >>> from canonical.testing.layers import MemcachedLayer
17+
18 >>> MemcachedLayer.purge()
19 >>> cached_milestone = factory.makeMilestone(
20 ... 'cache-test', productseries=series)
21@@ -315,11 +316,21 @@
22 >>> view = create_view(cached_milestone, '+index', principal=person)
23 >>> view.expire_cache_minutes
24 10
25+
26 >>> 'Cache hit' in view.render()
27 False
28- >>> print create_view(
29- ... cached_milestone, '+index', principal=person).render()
30- <...<!-- Cache hit: memcache expression
31+
32+ >>> content = find_main_content(create_view(
33+ ... cached_milestone, '+index', principal=person).render())
34+ >>> print find_tag_by_id(content, 'milestone-activities')
35+ <div id="milestone-activities" ...<!--
36+ Cache hit: memcache expression
37+ (private, view/expire_cache_minutes minute) [600 seconds] ...
38+ <dt>Assigned to you:</dt> ... No blueprints or bugs assigned to you. ...
39+
40+ >>> print find_tag_by_id(content, 'milestone-specs-bugs')
41+ <div id="milestone-specs-bugs" ...
42+ <!-- Cache hit: memcache expression
43 (private, view/expire_cache_minutes minute) [600 seconds] -->
44 <table class="listing sortable" id="milestone_bugtasks">...
45
46
47=== modified file 'lib/lp/registry/templates/distroseries-needs-packaging.pt'
48--- lib/lp/registry/templates/distroseries-needs-packaging.pt 2010-01-30 18:15:36 +0000
49+++ lib/lp/registry/templates/distroseries-needs-packaging.pt 2010-06-29 15:10:49 +0000
50@@ -47,7 +47,8 @@
51 </thead>
52
53 <tbody>
54- <tr tal:repeat="summary summaries/batch">
55+ <tr tal:repeat="summary summaries/batch"
56+ tal:content="cache:public, 30 minute">
57 <td>
58 <a class="sprite package-source"
59 tal:attributes="href summary/package/fmt:url"
60
61=== modified file 'lib/lp/registry/templates/distroseries-packaging.pt'
62--- lib/lp/registry/templates/distroseries-packaging.pt 2010-02-26 22:59:30 +0000
63+++ lib/lp/registry/templates/distroseries-packaging.pt 2010-06-29 15:10:49 +0000
64@@ -31,7 +31,8 @@
65 </ul>
66 </div>
67
68- <div tal:condition="packagings/batch">
69+ <div tal:condition="packagings/batch"
70+ tal:content="cache:public, 30 minute">
71 <h2>All upstream links</h2>
72
73 <div class="results"
74
75=== modified file 'lib/lp/registry/templates/milestone-index.pt'
76--- lib/lp/registry/templates/milestone-index.pt 2010-06-24 18:04:24 +0000
77+++ lib/lp/registry/templates/milestone-index.pt 2010-06-29 15:10:49 +0000
78@@ -128,8 +128,8 @@
79 </div>
80
81 <div class="yui-u">
82- <div class="portlet"
83- tal:content="cache:public, view/expire_cache_minutes minute">
84+ <div id="milestone-activities" class="portlet"
85+ tal:content="cache:private, view/expire_cache_minutes minute">
86 <h2>Activities</h2>
87
88 <dl>
89@@ -197,7 +197,7 @@
90 tal:condition="view/release"
91 tal:content="structure view/milestone/@@+productrelease-data" />
92
93- <div class="portlet full-page-width">
94+ <div id="milestone-specs-bugs" class="portlet full-page-width">
95 <h2>
96 <span id="specification-count" style="color: #3594bb;"
97 tal:content="structure view/specification_count_text">2</span>