Merge lp:~mvo/software-center/more-performance-measurement into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3043
Proposed branch: lp:~mvo/software-center/more-performance-measurement
Merge into: lp:software-center
Diff against target: 229 lines (+43/-32)
7 files modified
softwarecenter/ui/gtk3/app.py (+4/-11)
softwarecenter/ui/gtk3/models/appstore2.py (+4/-3)
softwarecenter/ui/gtk3/panes/availablepane.py (+13/-6)
softwarecenter/ui/gtk3/panes/softwarepane.py (+9/-7)
softwarecenter/ui/gtk3/session/viewmanager.py (+3/-2)
softwarecenter/ui/gtk3/views/appview.py (+3/-1)
softwarecenter/utils.py (+7/-2)
To merge this branch: bzr merge lp:~mvo/software-center/more-performance-measurement
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+111249@code.launchpad.net

Description of the change

This branch adds some more "probe" points that run "with ExecutionTime()" to get a better idea where the
time is spend on startup. To run:
$ ./software-center --measure-startup-time

It also adds a new limit of "0.1"s by default to avoid reportng time intervals that are mostly irrelevant.
Running this on my box shows that e.g. out of 4.6s startup until the window is fully ready about 1.2s
are spend in the apt cache open, 0.4s are spend parsing the applications menu and 0.6s creating the
LobbyViewGtk. So this branch should help figuring out what needs speedup or could be delayed/loaded in
the background.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Branch looks good.

This is the output from my box, but is worth noting that this was run using a 'warm' disk cache:

nessita@dali:~/canonical/software-center/review_more-performance-measurement$ PYTHONPATH=. ./software-center --measure-startup-time
2012-06-20 13:33:37,600 - softwarecenter.performance - DEBUG - create review loader: 0.164757013321
2012-06-20 13:33:37,607 - softwarecenter.performance - DEBUG - create SoftwareCenterApp: 0.29595708847
1340210018.0
2012-06-20 13:33:37,996 - softwarecenter.performance - DEBUG - ** main window visible after: 1.1121571064 seconds
2012-06-20 13:33:38,538 - softwarecenter.performance - DEBUG - open the apt cache (in event loop): 0.562124013901
2012-06-20 13:33:38,538 - softwarecenter.performance - DEBUG - AvailablePane.init_view pending events: 0.834131002426
2012-06-20 13:33:38,738 - softwarecenter.performance - DEBUG - cat_parser.parse_applications_menu(): 0.198755025864
2012-06-20 13:33:38,738 - softwarecenter.performance - DEBUG - Appview.__init__ create AppPropertiesHelper: 0.198960065842
2012-06-20 13:33:38,744 - softwarecenter.performance - DEBUG - SoftwarePane.AppView: 0.205328941345
2012-06-20 13:33:38,952 - softwarecenter.performance - DEBUG - SoftwarePane.AppDetailsView: 0.20628619194
2012-06-20 13:33:38,969 - softwarecenter.performance - DEBUG - SoftwarePane.init_view(): 0.430808067322
2012-06-20 13:33:39,334 - softwarecenter.performance - DEBUG - populate model from query: 'Xapian::Query((<alldocuments> AND ATapplication))' (threaded: False): 0.152559041977
2012-06-20 13:33:39,449 - softwarecenter.performance - DEBUG - create LobbyViewGtk: 0.447153091431
2012-06-20 13:33:39,606 - softwarecenter.performance - DEBUG - view_widget.init_view() (<AvailablePane object at 0x3276e60 (softwarecenter+ui+gtk3+panes+availablepane+AvailablePane at 0x311a6a0)>): 1.90255093575
2012-06-20 13:33:39,606 - softwarecenter.performance - DEBUG - show() & gtk events until visible: 1.99886608124
2.72254014015
2012-06-20 13:33:39,606 - softwarecenter.performance - DEBUG - ** main window fully ready after: 2.72254014015 seconds

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/app.py'
--- softwarecenter/ui/gtk3/app.py 2012-06-04 11:06:20 +0000
+++ softwarecenter/ui/gtk3/app.py 2012-06-20 15:47:25 +0000
@@ -349,8 +349,7 @@
349 datadir)349 datadir)
350350
351 # register view manager and create view panes/widgets351 # register view manager and create view panes/widgets
352 with ExecutionTime("ViewManager"):352 self.view_manager = ViewManager(self.notebook_view, options)
353 self.view_manager = ViewManager(self.notebook_view, options)
354353
355 with ExecutionTime("building panes"):354 with ExecutionTime("building panes"):
356 self.global_pane = GlobalPane(self.view_manager, self.datadir,355 self.global_pane = GlobalPane(self.view_manager, self.datadir,
@@ -416,11 +415,9 @@
416 self.useful_cache = UsefulnessCache(True)415 self.useful_cache = UsefulnessCache(True)
417 self.setup_database_rebuilding_listener()416 self.setup_database_rebuilding_listener()
418417
419 with ExecutionTime("create plugin manager"):418 # open plugin manager and load plugins
420 # open plugin manager and load plugins419 self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
421 self.plugin_manager = PluginManager(self,420 self.plugin_manager.load_plugins()
422 SOFTWARE_CENTER_PLUGIN_DIRS)
423 self.plugin_manager.load_plugins()
424421
425 # setup window name and about information (needs branding)422 # setup window name and about information (needs branding)
426 name = self.distro.get_app_name()423 name = self.distro.get_app_name()
@@ -485,7 +482,6 @@
485482
486 # keep track of the current active pane483 # keep track of the current active pane
487 self.active_pane = self.available_pane484 self.active_pane = self.available_pane
488 self.window_main.connect("realize", self.on_realize)
489485
490 # launchpad integration help, its ok if that fails486 # launchpad integration help, its ok if that fails
491 try:487 try:
@@ -552,9 +548,6 @@
552 pass548 pass
553549
554 # callbacks550 # callbacks
555 def on_realize(self, widget):
556 pass
557
558 def on_available_pane_created(self, widget):551 def on_available_pane_created(self, widget):
559 self.available_pane.searchentry.grab_focus()552 self.available_pane.searchentry.grab_focus()
560 self._update_recommendations_menuitem(553 self._update_recommendations_menuitem(
561554
=== modified file 'softwarecenter/ui/gtk3/models/appstore2.py'
--- softwarecenter/ui/gtk3/models/appstore2.py 2012-06-11 10:00:20 +0000
+++ softwarecenter/ui/gtk3/models/appstore2.py 2012-06-20 15:47:25 +0000
@@ -98,15 +98,16 @@
98 }98 }
9999
100 def __init__(self, db, cache, icons, icon_size=48,100 def __init__(self, db, cache, icons, icon_size=48,
101 global_icon_cache=False):101 global_icon_cache=False):
102 GObject.GObject.__init__(self)102 GObject.GObject.__init__(self)
103 self.db = db103 self.db = db
104 self.cache = cache104 self.cache = cache
105105
106 # get all categories106 # get all categories
107 cat_parser = CategoriesParser(db)107 cat_parser = CategoriesParser(db)
108 self.all_categories = cat_parser.parse_applications_menu(108 with ExecutionTime("cat_parser.parse_applications_menu()"):
109 softwarecenter.paths.APP_INSTALL_PATH)109 self.all_categories = cat_parser.parse_applications_menu(
110 softwarecenter.paths.APP_INSTALL_PATH)
110111
111 # reviews stats loader112 # reviews stats loader
112 self.review_loader = get_review_loader(cache, db)113 self.review_loader = get_review_loader(cache, db)
113114
=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-06-18 21:57:36 +0000
+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-06-20 15:47:25 +0000
@@ -51,6 +51,8 @@
51from softwarepane import SoftwarePane51from softwarepane import SoftwarePane
52from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager52from softwarecenter.ui.gtk3.session.viewmanager import get_viewmanager
53from softwarecenter.ui.gtk3.session.appmanager import get_appmanager53from softwarecenter.ui.gtk3.session.appmanager import get_appmanager
54from softwarecenter.utils import ExecutionTime
55
54from softwarecenter.backend.channel import SoftwareChannel56from softwarecenter.backend.channel import SoftwareChannel
55from softwarecenter.backend.unitylauncher import (UnityLauncher,57from softwarecenter.backend.unitylauncher import (UnityLauncher,
56 UnityLauncherInfo,58 UnityLauncherInfo,
@@ -132,12 +134,15 @@
132 if window is not None:134 if window is not None:
133 window.set_cursor(self.busy_cursor)135 window.set_cursor(self.busy_cursor)
134136
135 while Gtk.events_pending():137 with ExecutionTime("AvailablePane.init_view pending events"):
136 Gtk.main_iteration()138 while Gtk.events_pending():
139 Gtk.main_iteration()
137140
138 SoftwarePane.init_view(self)141 with ExecutionTime("SoftwarePane.init_view()"):
142 SoftwarePane.init_view(self)
139 # set the AppTreeView model, available pane uses list models143 # set the AppTreeView model, available pane uses list models
140 liststore = AppListStore(self.db, self.cache, self.icons)144 with ExecutionTime("create AppListStore"):
145 liststore = AppListStore(self.db, self.cache, self.icons)
141 #~ def on_appcount_changed(widget, appcount):146 #~ def on_appcount_changed(widget, appcount):
142 #~ self.subcategories_view._append_appcount(appcount)147 #~ self.subcategories_view._append_appcount(appcount)
143 #~ self.app_view._append_appcount(appcount)148 #~ self.app_view._append_appcount(appcount)
@@ -166,7 +171,8 @@
166 self.scroll_categories = Gtk.ScrolledWindow()171 self.scroll_categories = Gtk.ScrolledWindow()
167 self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,172 self.scroll_categories.set_policy(Gtk.PolicyType.AUTOMATIC,
168 Gtk.PolicyType.AUTOMATIC)173 Gtk.PolicyType.AUTOMATIC)
169 self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH,174 with ExecutionTime("create LobbyViewGtk"):
175 self.cat_view = LobbyViewGtk(self.datadir, APP_INSTALL_PATH,
170 self.cache,176 self.cache,
171 self.db,177 self.db,
172 self.icons,178 self.icons,
@@ -176,7 +182,8 @@
176 Gtk.Label(label="categories"))182 Gtk.Label(label="categories"))
177183
178 # sub-categories view184 # sub-categories view
179 self.subcategories_view = SubCategoryViewGtk(self.datadir,185 with ExecutionTime("create SubCategoryViewGtk"):
186 self.subcategories_view = SubCategoryViewGtk(self.datadir,
180 APP_INSTALL_PATH,187 APP_INSTALL_PATH,
181 self.cache,188 self.cache,
182 self.db,189 self.db,
183190
=== modified file 'softwarecenter/ui/gtk3/panes/softwarepane.py'
--- softwarecenter/ui/gtk3/panes/softwarepane.py 2012-06-18 20:26:49 +0000
+++ softwarecenter/ui/gtk3/panes/softwarepane.py 2012-06-20 15:47:25 +0000
@@ -211,8 +211,9 @@
211 self.search_aid = SearchAid(self)211 self.search_aid = SearchAid(self)
212 self.box_app_list.pack_start(self.search_aid, False, False, 0)212 self.box_app_list.pack_start(self.search_aid, False, False, 0)
213213
214 self.app_view = AppView(self.db, self.cache,214 with ExecutionTime("SoftwarePane.AppView"):
215 self.icons, self.show_ratings)215 self.app_view = AppView(self.db, self.cache,
216 self.icons, self.show_ratings)
216 self.app_view.connect("sort-method-changed",217 self.app_view.connect("sort-method-changed",
217 self.on_app_view_sort_method_changed)218 self.on_app_view_sort_method_changed)
218219
@@ -227,11 +228,12 @@
227 self.scroll_details = Gtk.ScrolledWindow()228 self.scroll_details = Gtk.ScrolledWindow()
228 self.scroll_details.set_policy(Gtk.PolicyType.AUTOMATIC,229 self.scroll_details.set_policy(Gtk.PolicyType.AUTOMATIC,
229 Gtk.PolicyType.AUTOMATIC)230 Gtk.PolicyType.AUTOMATIC)
230 self.app_details_view = AppDetailsView(self.db,231 with ExecutionTime("SoftwarePane.AppDetailsView"):
231 self.distro,232 self.app_details_view = AppDetailsView(self.db,
232 self.icons,233 self.distro,
233 self.cache,234 self.icons,
234 self.datadir)235 self.cache,
236 self.datadir)
235 self.app_details_view.connect(237 self.app_details_view.connect(
236 "different-application-selected", self.on_application_activated)238 "different-application-selected", self.on_application_activated)
237 self.scroll_details.add(self.app_details_view)239 self.scroll_details.add(self.app_details_view)
238240
=== modified file 'softwarecenter/ui/gtk3/session/viewmanager.py'
--- softwarecenter/ui/gtk3/session/viewmanager.py 2012-06-18 20:26:49 +0000
+++ softwarecenter/ui/gtk3/session/viewmanager.py 2012-06-20 15:47:25 +0000
@@ -21,7 +21,7 @@
21from navhistory import NavigationHistory, NavigationItem21from navhistory import NavigationHistory, NavigationItem
22from softwarecenter.ui.gtk3.widgets.backforward import BackForwardButton22from softwarecenter.ui.gtk3.widgets.backforward import BackForwardButton
23from softwarecenter.ui.gtk3.widgets.searchentry import SearchEntry23from softwarecenter.ui.gtk3.widgets.searchentry import SearchEntry
2424from softwarecenter.utils import ExecutionTime
2525
26_viewmanager = None # the global Viewmanager instance26_viewmanager = None # the global Viewmanager instance
2727
@@ -147,7 +147,8 @@
147147
148 self.notebook_view.set_current_page(page_id)148 self.notebook_view.set_current_page(page_id)
149 if view_widget:149 if view_widget:
150 view_widget.init_view()150 with ExecutionTime("view_widget.init_view() (%s)" % view_widget):
151 view_widget.init_view()
151 return view_widget152 return view_widget
152153
153 def get_active_view(self):154 def get_active_view(self):
154155
=== modified file 'softwarecenter/ui/gtk3/views/appview.py'
--- softwarecenter/ui/gtk3/views/appview.py 2012-05-30 18:39:55 +0000
+++ softwarecenter/ui/gtk3/views/appview.py 2012-06-20 15:47:25 +0000
@@ -27,6 +27,7 @@
27from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore27from softwarecenter.ui.gtk3.models.appstore2 import AppTreeStore
28from softwarecenter.ui.gtk3.widgets.apptreeview import AppTreeView28from softwarecenter.ui.gtk3.widgets.apptreeview import AppTreeView
29from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper29from softwarecenter.ui.gtk3.models.appstore2 import AppPropertiesHelper
30from softwarecenter.utils import ExecutionTime
3031
31LOG = logging.getLogger(__name__)32LOG = logging.getLogger(__name__)
3233
@@ -65,7 +66,8 @@
65 Gtk.VBox.__init__(self)66 Gtk.VBox.__init__(self)
66 #~ self.set_name("app-view")67 #~ self.set_name("app-view")
67 # app properties helper68 # app properties helper
68 self.helper = AppPropertiesHelper(db, cache, icons)69 with ExecutionTime("Appview.__init__ create AppPropertiesHelper"):
70 self.helper = AppPropertiesHelper(db, cache, icons)
69 # misc internal containers71 # misc internal containers
70 self.header_hbox = Gtk.HBox()72 self.header_hbox = Gtk.HBox()
71 self.header_hbox.set_border_width(StockEms.MEDIUM)73 self.header_hbox.set_border_width(StockEms.MEDIUM)
7274
=== modified file 'softwarecenter/utils.py'
--- softwarecenter/utils.py 2012-06-12 15:36:01 +0000
+++ softwarecenter/utils.py 2012-06-20 15:47:25 +0000
@@ -63,16 +63,21 @@
63 with ExecutinTime("db flush"):63 with ExecutinTime("db flush"):
64 db.flush()64 db.flush()
65 """65 """
66 def __init__(self, info="", with_traceback=False):66 def __init__(self, info="", with_traceback=False,
67 suppress_less_than_n_seconds=0.1):
67 self.info = info68 self.info = info
68 self.with_traceback = with_traceback69 self.with_traceback = with_traceback
70 self.suppress_less_than_n_seconds = suppress_less_than_n_seconds
6971
70 def __enter__(self):72 def __enter__(self):
71 self.now = time.time()73 self.now = time.time()
7274
73 def __exit__(self, type, value, stack):75 def __exit__(self, type, value, stack):
76 time_spend = time.time() - self.now
77 if time_spend < self.suppress_less_than_n_seconds:
78 return
74 logger = logging.getLogger("softwarecenter.performance")79 logger = logging.getLogger("softwarecenter.performance")
75 logger.debug("%s: %s" % (self.info, time.time() - self.now))80 logger.debug("%s: %s" % (self.info, time_spend))
76 if self.with_traceback:81 if self.with_traceback:
77 log_traceback("populate model from query: '%s' (threaded: %s)")82 log_traceback("populate model from query: '%s' (threaded: %s)")
7883

Subscribers

People subscribed via source and target branches