Merge lp:~mvo/software-center/performance-probes into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2600
Proposed branch: lp:~mvo/software-center/performance-probes
Merge into: lp:software-center
Diff against target: 263 lines (+100/-93)
2 files modified
software-center (+6/-8)
softwarecenter/ui/gtk3/app.py (+94/-85)
To merge this branch: bzr merge lp:~mvo/software-center/performance-probes
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Michael Vogt Pending
Review via email: mp+85745@code.launchpad.net

Description of the change

This branch adds a more accurate startup time measurement. It will now wait until the lobby view is ready before it exists. It will also add some "probe" points to make the profiling easier.

To post a comment you must log in.
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Looks good, thanks mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'software-center'
--- software-center 2011-10-28 20:34:16 +0000
+++ software-center 2011-12-14 20:53:25 +0000
@@ -135,18 +135,16 @@
135 # DEBUG/PROFILE mode 135 # DEBUG/PROFILE mode
136 if options.measure_startup_time:136 if options.measure_startup_time:
137 with ExecutionTime("show() & gtk events until visible"):137 with ExecutionTime("show() & gtk events until visible"):
138# app.window_main.show_all()138 app.run(args)
139 while Gtk.events_pending():139 while not (app.available_pane.cat_view and
140 # test visible area140 app.available_pane.cat_view.get_visible()):
141 if (app.window_main.get_visible() and141 while Gtk.events_pending():
142 app.available_pane.searchentry.get_visible() and142 Gtk.main_iteration()
143 app.available_pane.back_forward.get_visible):
144 break
145 Gtk.main_iteration()
146 time_to_visible = time.time() - time_entering_main143 time_to_visible = time.time() - time_entering_main
147 print(time_to_visible)144 print(time_to_visible)
148 sys.exit(0)145 sys.exit(0)
149146
150 # run it normally147 # run it normally
151 app.run(args)148 app.run(args)
149 Gtk.main()
152150
153151
=== modified file 'softwarecenter/ui/gtk3/app.py'
--- softwarecenter/ui/gtk3/app.py 2011-11-29 20:04:18 +0000
+++ softwarecenter/ui/gtk3/app.py 2011-12-14 20:53:25 +0000
@@ -62,6 +62,7 @@
62from softwarecenter.utils import (clear_token_from_ubuntu_sso,62from softwarecenter.utils import (clear_token_from_ubuntu_sso,
63 get_http_proxy_string_from_gsettings,63 get_http_proxy_string_from_gsettings,
64 wait_for_apt_cache_ready,64 wait_for_apt_cache_ready,
65 ExecutionTime,
65 is_unity_running)66 is_unity_running)
66from softwarecenter.ui.gtk3.utils import (get_sc_icon_theme,67from softwarecenter.ui.gtk3.utils import (get_sc_icon_theme,
67 init_sc_css_provider)68 init_sc_css_provider)
@@ -209,49 +210,53 @@
209 sources = self.builder.get_object("menuitem_software_sources")210 sources = self.builder.get_object("menuitem_software_sources")
210 sources.set_sensitive(False)211 sources.set_sensitive(False)
211212
212 # a main iteration friendly apt cache213 with ExecutionTime("opening the pkginfo"):
213 self.cache = get_pkg_info()214 # a main iteration friendly apt cache
214 self.cache.open()215 self.cache = get_pkg_info()
215 self.cache.connect("cache-broken", self._on_apt_cache_broken)216 self.cache.open()
217 self.cache.connect("cache-broken", self._on_apt_cache_broken)
216218
217 # xapian219 with ExecutionTime("opening the xapiandb"):
218 pathname = os.path.join(xapian_base_path, "xapian")220 pathname = os.path.join(xapian_base_path, "xapian")
219 self._use_axi = not options.disable_apt_xapian_index221 self._use_axi = not options.disable_apt_xapian_index
220 try:222 try:
221 self.db = StoreDatabase(pathname, self.cache)223 self.db = StoreDatabase(pathname, self.cache)
222 self.db.open(use_axi = self._use_axi)224 self.db.open(use_axi = self._use_axi)
223 if self.db.schema_version() != DB_SCHEMA_VERSION:225 if self.db.schema_version() != DB_SCHEMA_VERSION:
224 LOG.warn("database format '%s' expected, but got '%s'" % (226 LOG.warn("database format '%s' expected, but got '%s'" % (
225 DB_SCHEMA_VERSION, self.db.schema_version()))227 DB_SCHEMA_VERSION, self.db.schema_version()))
226 if os.access(pathname, os.W_OK):228 if os.access(pathname, os.W_OK):
229 self._rebuild_and_reopen_local_db(pathname)
230 except xapian.DatabaseOpeningError:
231 # Couldn't use that folder as a database
232 # This may be because we are in a bzr checkout and that
233 # folder is empty. If the folder is empty, and we can find the
234 # script that does population, populate a database in it.
235 if os.path.isdir(pathname) and not os.listdir(pathname):
227 self._rebuild_and_reopen_local_db(pathname)236 self._rebuild_and_reopen_local_db(pathname)
228 except xapian.DatabaseOpeningError:237 except xapian.DatabaseCorruptError:
229 # Couldn't use that folder as a database238 LOG.exception("xapian open failed")
230 # This may be because we are in a bzr checkout and that239 dialogs.error(None,
231 # folder is empty. If the folder is empty, and we can find the240 _("Sorry, can not open the software database"),
232 # script that does population, populate a database in it.241 _("Please re-install the 'software-center' "
233 if os.path.isdir(pathname) and not os.listdir(pathname):242 "package."))
234 self._rebuild_and_reopen_local_db(pathname)243 # FIXME: force rebuild by providing a dbus service for this
235 except xapian.DatabaseCorruptError:244 sys.exit(1)
236 LOG.exception("xapian open failed")
237 dialogs.error(None,
238 _("Sorry, can not open the software database"),
239 _("Please re-install the 'software-center' "
240 "package."))
241 # FIXME: force rebuild by providing a dbus service for this
242 sys.exit(1)
243245
244 # additional icons come from app-install-data246 # additional icons come from app-install-data
245 self.icons = get_sc_icon_theme(self.datadir)247 with ExecutionTime("building the icon cache"):
248 self.icons = get_sc_icon_theme(self.datadir)
246249
247 # backend250 # backend
248 self.backend = get_install_backend()251 with ExecutionTime("creating the backend"):
249 self.backend.ui = InstallBackendUI()252 self.backend = get_install_backend()
250 self.backend.connect("transaction-finished", self._on_transaction_finished)253 self.backend.ui = InstallBackendUI()
251 self.backend.connect("channels-changed", self.on_channels_changed)254 self.backend.connect("transaction-finished", self._on_transaction_finished)
255 self.backend.connect("channels-changed", self.on_channels_changed)
252256
253 # high level app management257 # high level app management
254 self.app_manager = ApplicationManager(self.db, self.backend, self.icons)258 with ExecutionTime("get the app-manager"):
259 self.app_manager = ApplicationManager(self.db, self.backend, self.icons)
255260
256 # misc state261 # misc state
257 self._block_menuitem_view = False262 self._block_menuitem_view = False
@@ -276,43 +281,45 @@
276 datadir)281 datadir)
277282
278 # register view manager and create view panes/widgets283 # register view manager and create view panes/widgets
279 self.view_manager = ViewManager(self.notebook_view, options)284 with ExecutionTime("ViewManager"):
280285 self.view_manager = ViewManager(self.notebook_view, options)
281 self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons)286
282 self.vbox1.pack_start(self.global_pane, False, False, 0)287 with ExecutionTime("building panes"):
283 self.vbox1.reorder_child(self.global_pane, 1)288 self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons)
284289 self.vbox1.pack_start(self.global_pane, False, False, 0)
285 # available pane290 self.vbox1.reorder_child(self.global_pane, 1)
286 self.available_pane = AvailablePane(self.cache,291
292 # available pane
293 self.available_pane = AvailablePane(self.cache,
294 self.db,
295 self.distro,
296 self.icons,
297 self.datadir,
298 self.navhistory_back_action,
299 self.navhistory_forward_action)
300 self.available_pane.connect("available-pane-created", self.on_available_pane_created)
301 self.view_manager.register(self.available_pane, ViewPages.AVAILABLE)
302
303 # installed pane (view not fully initialized at this point)
304 self.installed_pane = InstalledPane(self.cache,
305 self.db,
306 self.distro,
307 self.icons,
308 self.datadir)
309 #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created)
310 self.view_manager.register(self.installed_pane, ViewPages.INSTALLED)
311
312 # history pane (not fully loaded at this point)
313 self.history_pane = HistoryPane(self.cache,
287 self.db,314 self.db,
288 self.distro,315 self.distro,
289 self.icons,316 self.icons,
290 self.datadir,
291 self.navhistory_back_action,
292 self.navhistory_forward_action)
293 self.available_pane.connect("available-pane-created", self.on_available_pane_created)
294 self.view_manager.register(self.available_pane, ViewPages.AVAILABLE)
295
296 # installed pane (view not fully initialized at this point)
297 self.installed_pane = InstalledPane(self.cache,
298 self.db,
299 self.distro,
300 self.icons,
301 self.datadir)317 self.datadir)
302 #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created)318 self.view_manager.register(self.history_pane, ViewPages.HISTORY)
303 self.view_manager.register(self.installed_pane, ViewPages.INSTALLED)319
304320 # pending pane
305 # history pane (not fully loaded at this point)321 self.pending_pane = PendingPane(self.icons)
306 self.history_pane = HistoryPane(self.cache,322 self.view_manager.register(self.pending_pane, ViewPages.PENDING)
307 self.db,
308 self.distro,
309 self.icons,
310 self.datadir)
311 self.view_manager.register(self.history_pane, ViewPages.HISTORY)
312
313 # pending pane
314 self.pending_pane = PendingPane(self.icons)
315 self.view_manager.register(self.pending_pane, ViewPages.PENDING)
316323
317 # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help324 # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help
318 self.menuitem_help.set_label(_("%s _Help")%self.distro.get_app_name())325 self.menuitem_help.set_label(_("%s _Help")%self.distro.get_app_name())
@@ -321,16 +328,18 @@
321 self.window_main.set_size_request(730, 470)328 self.window_main.set_size_request(730, 470)
322329
323 # reviews330 # reviews
324 self.review_loader = get_review_loader(self.cache, self.db)331 with ExecutionTime("create review loader"):
325 # FIXME: add some kind of throttle, I-M-S here332 self.review_loader = get_review_loader(self.cache, self.db)
326 self.review_loader.refresh_review_stats(self.on_review_stats_loaded)333 # FIXME: add some kind of throttle, I-M-S here
327 #load usefulness votes from server when app starts334 self.review_loader.refresh_review_stats(self.on_review_stats_loaded)
328 self.useful_cache = UsefulnessCache(True)335 #load usefulness votes from server when app starts
329 self.setup_database_rebuilding_listener()336 self.useful_cache = UsefulnessCache(True)
337 self.setup_database_rebuilding_listener()
330338
331 # open plugin manager and load plugins339 with ExecutionTime("create plugin manager"):
332 self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)340 # open plugin manager and load plugins
333 self.plugin_manager.load_plugins()341 self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
342 self.plugin_manager.load_plugins()
334343
335 # setup window name and about information (needs branding)344 # setup window name and about information (needs branding)
336 name = self.distro.get_app_name()345 name = self.distro.get_app_name()
@@ -384,13 +393,14 @@
384 if not (options.enable_lp or och):393 if not (options.enable_lp or och):
385 file_menu.remove(self.builder.get_object("separator_login"))394 file_menu.remove(self.builder.get_object("separator_login"))
386 else:395 else:
387 sc_agent_update = os.path.join(396 with ExecutionTime("run update-software-center-agent"):
388 self.datadir, "update-software-center-agent")397 sc_agent_update = os.path.join(
389 (pid, stdin, stdout, stderr) = GObject.spawn_async(398 self.datadir, "update-software-center-agent")
390 [sc_agent_update, "--datadir", datadir], 399 (pid, stdin, stdout, stderr) = GObject.spawn_async(
391 flags=GObject.SPAWN_DO_NOT_REAP_CHILD)400 [sc_agent_update, "--datadir", datadir],
392 GObject.child_watch_add(401 flags=GObject.SPAWN_DO_NOT_REAP_CHILD)
393 pid, self._on_update_software_center_agent_finished)402 GObject.child_watch_add(
403 pid, self._on_update_software_center_agent_finished)
394404
395 # TODO: Remove the following two lines once we have remove repository405 # TODO: Remove the following two lines once we have remove repository
396 # support in aptdaemon (see LP: #723911)406 # support in aptdaemon (see LP: #723911)
@@ -1223,4 +1233,3 @@
1223 self.show_available_packages(args)1233 self.show_available_packages(args)
12241234
1225 atexit.register(self.save_state)1235 atexit.register(self.save_state)
1226 SimpleGtkbuilderApp.run(self)

Subscribers

People subscribed via source and target branches