← Back to team overview

launchpad-dev team mailing list archive

Re: performance tuesday - a few notes

 

Oh, and the patch:

=== modified file 'lib/lp/soyuz/adapters/archivesourcepublication.py'
--- lib/lp/soyuz/adapters/archivesourcepublication.py	2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/adapters/archivesourcepublication.py	2010-08-10 08:35:15 +0000
@@ -89,6 +89,8 @@
         # ISourcePackagePublishingHistory.getStatusSummaryForBuilds() but
         # using the delegate as self - might not be possible without
         # duck-typing.
+        print "woooooXXX"
+        import pdb;pdb.set_trace()
         return getUtility(
             IPublishingSet).getBuildStatusSummaryForSourcePublication(self)


=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py	2010-08-10
05:02:52 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py	2010-08-10
06:32:34 +0000
@@ -3,6 +3,8 @@

 # pylint: disable-msg=F0401

+from __future__ import with_statement
+
 """Unit tests for TestP3APackages."""

 __metaclass__ = type
@@ -12,12 +14,21 @@
     'test_suite',
     ]

+from testtools.matchers import LessThan
+from zope.component import getUtility
 from zope.security.interfaces import Unauthorized

+from canonical.launchpad.webapp import canonical_url
 from canonical.testing import LaunchpadFunctionalLayer
+from lp.registry.interfaces.distribution import IDistributionSet
 from lp.soyuz.browser.archive import ArchiveNavigationMenu
-from lp.testing import login, login_person, TestCaseWithFactory
+from lp.soyuz.interfaces.publishing import PackagePublishingStatus
+from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
+from lp.testing import login, logout, login_person, TestCaseWithFactory
+from lp.testing.matchers import HasQueryCount
+from lp.testing.sampledata import LAUNCHPAD_ADMIN
 from lp.testing.views import create_initialized_view
+from lp.testing._webservice import QueryCollector


 class TestP3APackages(TestCaseWithFactory):
@@ -28,7 +39,7 @@
     def setUp(self):
         super(TestP3APackages, self).setUp()
         self.private_ppa = self.factory.makeArchive(description='Foo')
-        login('admin@xxxxxxxxxxxxx')
+        login(LAUNCHPAD_ADMIN)
         self.private_ppa.buildd_secret = 'blah'
         self.private_ppa.private = True
         self.joe = self.factory.makePerson(name='joe')
@@ -92,3 +103,41 @@
         view = create_initialized_view(ppa, "+index")
         menu = ArchiveNavigationMenu(view)
         self.assertTrue(menu.packages().enabled)
+
+    def test_ppa_packages_query_limit(self):
+        # Rendering a PPA should not chatter to the DB too much, and should
+        # stay constant as the package count increases.
+        # This test trys to capture the obvious way in which the page might
+        # scale badly: multiple packages.
+        ppa = self.factory.makeArchive()
+        test_publisher = SoyuzTestPublisher()
+        ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
+        hoary = ubuntu.getSeries('hoary')
+        test_publisher.addFakeChroots(hoary)
+        test_publisher.setUpDefaultDistroSeries(hoary)
+        # person_logged_in does not accept emails.
+        login(LAUNCHPAD_ADMIN)
+        try:
+            test_publisher.getPubBinaries('binary1',
distroseries=hoary, archive=ppa)
+            test_publisher.getPubBinaries('binary2',
distroseries=hoary, archive=ppa)
+        finally:
+            logout()
+        login_person(ppa.owner)
+        collector = QueryCollector()
+        collector.register()
+        self.addCleanup(collector.unregister)
+        browser = self.getUserBrowser(canonical_url(ppa) + "/+packages")
+        # This page is terrible: 47 queries as a baseline in 20100810
+        page_query_limit = 47
+        self.assertThat(collector, HasQueryCount(LessThan(page_query_limit)))
+        with_2_count = collector.count
+        login(LAUNCHPAD_ADMIN)
+        try:
+            test_publisher.getPubBinaries('binary3',
distroseries=hoary, archive=ppa)
+        finally:
+            logout()
+        login_person(ppa.owner)
+        browser = self.getUserBrowser(canonical_url(ppa) + "/+packages")
+        self.assertThat(collector, HasQueryCount(LessThan(page_query_limit)))
+        with_3_count = collector.count
+        self.assertEqual(with_2_count, with_3_count)

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2010-08-02 02:13:52 +0000
+++ lib/lp/soyuz/model/publishing.py	2010-08-10 08:20:34 +0000
@@ -43,6 +43,7 @@
     IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR)
 from canonical.launchpad.webapp.errorlog import (
     ErrorReportingUtility, ScriptRequest)
+from canonical.lazr.utils import safe_hasattr
 from lp.app.errors import NotFoundError
 from lp.buildmaster.interfaces.buildbase import BuildStatus
 from lp.buildmaster.model.buildfarmjob import BuildFarmJob
@@ -364,6 +365,9 @@

 class SourcePackagePublishingHistory(SQLBase, ArchivePublisherBase):
     """A source package release publishing record."""
+    # ArchivePublisherBase is an odd base class for this -
+    # fundamentally different intents.
+
     implements(ISourcePackagePublishingHistory)

     sourcepackagerelease = ForeignKey(foreignKey='SourcePackageRelease',



References