Merge lp:~adeuring/launchpad/bug-518746-faster-retrieval-of-patch-age into lp:launchpad/db-devel
| Status: | Merged |
|---|---|
| Merged at revision: | not available |
| Proposed branch: | lp:~adeuring/launchpad/bug-518746-faster-retrieval-of-patch-age |
| Merge into: | lp:launchpad/db-devel |
| Diff against target: |
227 lines (+75/-40) 6 files modified
lib/lp/bugs/browser/bugtarget.py (+0/-17) lib/lp/bugs/configure.zcml (+1/-0) lib/lp/bugs/doc/bug.txt (+39/-15) lib/lp/bugs/interfaces/bug.py (+2/-0) lib/lp/bugs/model/bug.py (+26/-1) lib/lp/bugs/templates/bugtarget-patches.pt (+7/-7) |
| To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-518746-faster-retrieval-of-patch-age |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Brad Crittenden (community) | code | 2010-02-09 | Approve on 2010-02-09 |
|
Review via email:
|
|||
| Abel Deuring (adeuring) wrote : | # |
| Abel Deuring (adeuring) wrote : | # |
sorry copy&paste error with the lint output... The complete lint message:
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/
333: [C0322, FileBugViewBase
failure=
^
def submit_
511: [C0322, FileBugViewBase
name=
^
def this_is_
883: [C0322, FileBugGuidedVi
validator=
^
def continue_
lib/lp/
50: [F0401] Unable to import 'lazr.restful.
56: [F0401] Unable to import 'lazr.restful.
57: [F0401] Unable to import 'lazr.restful.
501: [C0322, IBug.addAttachment] Operator not preceded by a space
comment=Text(), filename=
^
content_
@export_
def addAttachment(
content_
636: [C0322, IBug.getNominat
nominations
^
title=
value_
required=
@operation_
@export_
def getNominations(
716: [C0322, IBug.markUserAf
required=False, default=True))
^
@call_
@export_
def markUserAffecte
731: [C0322, IBug.setComment
required=True),
^
visible=
@call_
@export_
def setCommentVisib
743: [C0322, IBug.linkHWSubm
Interface, title=_(...
| Brad Crittenden (bac) wrote : | # |
Hi Abel,
Thanks for the nice work to solve those timeouts. Here are some suggestions to improve the branch.
* I think in bug.txt you are missing one test: when there are multiple patches and the latest patch is deleted. In that case I assume the next oldest is shown, correct? Having that demonstrated in the test would be great. It'll also make the property regression-proof in the event someone decided to cache the latest patch rather than doing a query.
* s/The most recently patch of this bug./The most recent patch of this bug./
* s/datecrated/
* In your template I'd discourage the use of the one letter variable name 'p' (though I recognized you inherited it.)
| Abel Deuring (adeuring) wrote : | # |
Hi Brad,
thanks for your review!
On 09.02.2010 19:59, Brad Crittenden wrote:
> Review: Approve code
> Hi Abel,
>
> Thanks for the nice work to solve those timeouts. Here are some suggestions to improve the branch.
>
> * I think in bug.txt you are missing one test: when there are multiple patches and the latest patch is deleted. In that case I assume the next oldest is shown, correct? Having that demonstrated in the test would be great. It'll also make the property regression-proof in the event someone decided to cache the latest patch rather than doing a query.
Good idea, I extended the tests a bit.
>
> * s/The most recently patch of this bug./The most recent patch of this bug./
Fixed.
>
> * s/datecrated/
Fixed.
>
> * In your template I'd discourage the use of the one letter variable name 'p' (though I recognized you inherited it.)
Fixed.
Aebl
| Abel Deuring (adeuring) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Brad,
thanks for your review!
On 09.02.2010 19:59, Brad Crittenden wrote:
> Review: Approve code
> Hi Abel,
>
> Thanks for the nice work to solve those timeouts. Here are some suggestions to improve the branch.
>
> * I think in bug.txt you are missing one test: when there are multiple patches and the latest patch is deleted. In that case I assume the next oldest is shown, correct? Having that demonstrated in the test would be great. It'll also make the property regression-proof in the event someone decided to cache the latest patch rather than doing a query.
Good idea, I extended the tests a bit.
>
> * s/The most recently patch of this bug./The most recent patch of this bug./
>
Fixed.
> * s/datecrated/
Fixed.
>
> * In your template I'd discourage the use of the one letter variable name 'p' (though I recognized you inherited it.)
Fixed.
Abel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iD8DBQFLccKIekB
kpwtKELVUwXrt9A
=iC3D
-----END PGP SIGNATURE-----

This branch fixes timeout OOPSes that consistenly occur on the new +patches view, for nearly all targets. Examples: https:/ /staging. launchpad. net/ubuntu/ +patches , https:/ /bugs.staging. launchpad. net/~adeuring/ +patches
The OOPS reports show that ca. 15 seconds are spent with ca 30-40 queries which retrieve the bug attachments for a given bug. Each of these queries needs 300..500 milliseconds; they are issued for each of the up to 50 bug tasks we display on the +patches page.
The queries are issued by the method BugsPatchesView .youngestPatch( ), which looks for the most recently added patch attachment by iterating over Bug.attachments.
The fix is quite straightforward: We don't need to retrieve all bug attachments of a bug, if we can directly find the one we are interested in using a "better" SQL query.
So I added a property Bug.latest_patch, which does just that: return the most recentl added patch attachment.
As noted in a comment in model/bug.py, the result is in very rare cases not necessarily exact, but I think the inaccuracy does not matter in this case. The alternative would have been to query over the joined tables BugAttachment and Message, and to sort by Message. datecreated, which would be much slower, since Message.datecreated is not indexed.
Chex already EXPLAIN ANALYZEd the new query on staging: It needs ca 40 milliseconds -- not blindingly fast, but, with a total execution time of ca 2 seconds for 50 bugtasks, "good enough" for the +patches view, I think.
tests:
./bin/test -vvv -t patches-view.txt
./bin/test -vvv -t doc/bug.txt
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: bugs/configure. zcml bugs/browser/ bugtarget. py bugs/doc/ bug.txt bugs/interfaces /bug.py bugs/model/ bug.py bugs/templates/ bugtarget- patches. pt
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ bugs/browser/ bugtarget. py .submit_ bug_action] Operator not preceded by a space handleSubmitBug Failure) bug_action( self, action, data): .this_is_ my_bug_ action] Operator not preceded by a space "this_is_ my_bug" , failure= handleSubmitBug Failure) my_bug_ action( self, action, data): ew.continue_ action] Operator not preceded by a space "validate_ no_dupe_ found") action( self, action, data):
333: [C0322, FileBugViewBase
failure=
^
def submit_
511: [C0322, FileBugViewBase
name=
^
def this_is_
883: [C0322, FileBugGuidedVi
validator=
^
def continue_
lib/lp/ bugs/interfaces /bug.py declarations' (No module named restful)
50: [F0401] Unable to import 'lazr.restful.
...