Merge lp://staging/~gary/launchpad/bug724025 into lp://staging/launchpad
Status: | Merged |
---|---|
Approved by: | Gary Poster |
Approved revision: | no longer in the source branch. |
Merged at revision: | 13850 |
Proposed branch: | lp://staging/~gary/launchpad/bug724025 |
Merge into: | lp://staging/launchpad |
Diff against target: |
173 lines (+87/-8) 5 files modified
lib/lp/bugs/browser/bugtask.py (+9/-4) lib/lp/bugs/browser/tests/test_bugtask.py (+42/-0) lib/lp/bugs/model/bug.py (+2/-2) lib/lp/code/model/branchcollection.py (+11/-2) lib/lp/code/model/tests/test_branchcollection.py (+23/-0) |
To merge this branch: | bzr merge lp://staging/~gary/launchpad/bug724025 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+73432@code.staging.launchpad.net |
Commit message
[r=jtv][bug=724025] implement some low-hanging optimizations when a bug has many branches.
Description of the change
This tries again to implement some low-hanging optimizations when a bug has many branches.
The main idea of the code was already approved.
https:/
However, that version was qa-bad: it turned out that when a bug didn't have any branches at all, my optimization was getting *all merge proposals* in the system. OOPS, as it were.
To fix this, I made two changes. In the bugtask code I had added before, if there are no branches, I don't bother to try and call getMergeProposals. This alone would still leave a trap for others, though, so I also made getMergeProposals be more careful: if you pass None for branches or revisions, that means no restriction; but if you pass an empty collection, that means you don't get any results. IOW, if you want merge proposals that are associated with an empty set of branches, that results in an empty set of merge proposals.
Thank you
Hi Gary,
Nice cover letter. Worth a chuckle.
The distinction between None and [] makes perfect sense to me. Just a very few nitpicks:
=== modified file 'lib/lp/ bugs/browser/ bugtask. py' bugs/browser/ bugtask. py 2011-08-30 16:43:16 +0000 bugs/browser/ bugtask. py 2011-08-30 19:47:25 +0000
--- lib/lp/
+++ lib/lp/
@@ -882,10 +883,18 @@ perty branches( self): bug.linked_ branches: n('launchpad. View', linked_ branch. branch) : branches. append( linked_ branch) bug.getVisibleL inkedBranches( (IAllBranches) .getMergePropos als( [link.branch for link in linked_branches],
@cachedpro
def linked_
"""Filter out the bug_branch links to non-visible private branches."""
- linked_branches = []
- for linked_branch in self.context.
- if check_permissio
- linked_
+ linked_branches = list(
+ self.context.
+ self.user, eager_load=True))
+ # This is an optimization for when we look at the merge proposals.
+ # Note that, like all of these sorts of Storm cache optimizations, it
+ # only helps if [launchpad] storm_cache_size in launchpad-lazr.conf is
+ # pretty big--and as of this writing, it isn't for developer
+ # instances.
+ if linked_branches:
+ list(getUtility
+ for_branches=
+ eager_load=True))
The comment about dev cache sizes makes me nervous. Is it that noticeable? On dev systems I would expect cold-start overhead to dominate anyway. Or if it's not a dramatic issue, I'd just leave that note out.
=== modified file 'lib/lp/ bugs/browser/ tests/test_ bugtask. py' bugs/browser/ tests/test_ bugtask. py 2011-08-30 16:43:16 +0000 bugs/browser/ tests/test_ bugtask. py 2011-08-30 19:47:25 +0000
self. factory. makeBugAttachme nt(bug= task.bug)
self. assertThat( task, browses_ under_limit)
--- lib/lp/
+++ lib/lp/
@@ -124,6 +124,51 @@
+ def test_rendered_ query_counts_ reduced_ with_branches( self): ies() kageName( 'testsourcepack agename% d' % i) kage( me=name, distroseries=ds, publish=True) bug=bug, owner=owner, target=sp) append( bugtask) (recorder. unregister) _caches( task) wser(url, owner) (recorder, HasQueryCount( LessThan( 100))) no_branches = recorder.count _caches( task) logged_ in(owner) : anch( sp,...
+ f = self.factory
+ owner = f.makePerson()
+ ds = f.makeDistroSer
+ sourcepackagenames = [
+ f.makeSourcePac
+ for i in range(10)]
+ sourcepackages = [
+ f.makeSourcePac
+ sourcepackagena
+ for name in sourcepackagenames]
+ bug = f.makeBug()
+ bugtasks = []
+ for sp in sourcepackages:
+ bugtask = f.makeBugTask(
+ bugtasks.
+ task = bugtasks[0]
+ url = canonical_url(task)
+ recorder = QueryCollector()
+ recorder.register()
+ self.addCleanup
+ self.invalidate
+ self.getUserBro
+ # At least 20 of these should be removed.
+ self.assertThat
+ count_with_
+ self.invalidate
+ with person_
+ for sp in sourcepackages:
+ target_branch = f.makePackageBr
+ sourcepackage=