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
1=== modified file 'software-center'
2--- software-center 2011-10-28 20:34:16 +0000
3+++ software-center 2011-12-14 20:53:25 +0000
4@@ -135,18 +135,16 @@
5 # DEBUG/PROFILE mode
6 if options.measure_startup_time:
7 with ExecutionTime("show() & gtk events until visible"):
8-# app.window_main.show_all()
9- while Gtk.events_pending():
10- # test visible area
11- if (app.window_main.get_visible() and
12- app.available_pane.searchentry.get_visible() and
13- app.available_pane.back_forward.get_visible):
14- break
15- Gtk.main_iteration()
16+ app.run(args)
17+ while not (app.available_pane.cat_view and
18+ app.available_pane.cat_view.get_visible()):
19+ while Gtk.events_pending():
20+ Gtk.main_iteration()
21 time_to_visible = time.time() - time_entering_main
22 print(time_to_visible)
23 sys.exit(0)
24
25 # run it normally
26 app.run(args)
27+ Gtk.main()
28
29
30=== modified file 'softwarecenter/ui/gtk3/app.py'
31--- softwarecenter/ui/gtk3/app.py 2011-11-29 20:04:18 +0000
32+++ softwarecenter/ui/gtk3/app.py 2011-12-14 20:53:25 +0000
33@@ -62,6 +62,7 @@
34 from softwarecenter.utils import (clear_token_from_ubuntu_sso,
35 get_http_proxy_string_from_gsettings,
36 wait_for_apt_cache_ready,
37+ ExecutionTime,
38 is_unity_running)
39 from softwarecenter.ui.gtk3.utils import (get_sc_icon_theme,
40 init_sc_css_provider)
41@@ -209,49 +210,53 @@
42 sources = self.builder.get_object("menuitem_software_sources")
43 sources.set_sensitive(False)
44
45- # a main iteration friendly apt cache
46- self.cache = get_pkg_info()
47- self.cache.open()
48- self.cache.connect("cache-broken", self._on_apt_cache_broken)
49+ with ExecutionTime("opening the pkginfo"):
50+ # a main iteration friendly apt cache
51+ self.cache = get_pkg_info()
52+ self.cache.open()
53+ self.cache.connect("cache-broken", self._on_apt_cache_broken)
54
55- # xapian
56- pathname = os.path.join(xapian_base_path, "xapian")
57- self._use_axi = not options.disable_apt_xapian_index
58- try:
59- self.db = StoreDatabase(pathname, self.cache)
60- self.db.open(use_axi = self._use_axi)
61- if self.db.schema_version() != DB_SCHEMA_VERSION:
62- LOG.warn("database format '%s' expected, but got '%s'" % (
63- DB_SCHEMA_VERSION, self.db.schema_version()))
64- if os.access(pathname, os.W_OK):
65+ with ExecutionTime("opening the xapiandb"):
66+ pathname = os.path.join(xapian_base_path, "xapian")
67+ self._use_axi = not options.disable_apt_xapian_index
68+ try:
69+ self.db = StoreDatabase(pathname, self.cache)
70+ self.db.open(use_axi = self._use_axi)
71+ if self.db.schema_version() != DB_SCHEMA_VERSION:
72+ LOG.warn("database format '%s' expected, but got '%s'" % (
73+ DB_SCHEMA_VERSION, self.db.schema_version()))
74+ if os.access(pathname, os.W_OK):
75+ self._rebuild_and_reopen_local_db(pathname)
76+ except xapian.DatabaseOpeningError:
77+ # Couldn't use that folder as a database
78+ # This may be because we are in a bzr checkout and that
79+ # folder is empty. If the folder is empty, and we can find the
80+ # script that does population, populate a database in it.
81+ if os.path.isdir(pathname) and not os.listdir(pathname):
82 self._rebuild_and_reopen_local_db(pathname)
83- except xapian.DatabaseOpeningError:
84- # Couldn't use that folder as a database
85- # This may be because we are in a bzr checkout and that
86- # folder is empty. If the folder is empty, and we can find the
87- # script that does population, populate a database in it.
88- if os.path.isdir(pathname) and not os.listdir(pathname):
89- self._rebuild_and_reopen_local_db(pathname)
90- except xapian.DatabaseCorruptError:
91- LOG.exception("xapian open failed")
92- dialogs.error(None,
93- _("Sorry, can not open the software database"),
94- _("Please re-install the 'software-center' "
95- "package."))
96- # FIXME: force rebuild by providing a dbus service for this
97- sys.exit(1)
98+ except xapian.DatabaseCorruptError:
99+ LOG.exception("xapian open failed")
100+ dialogs.error(None,
101+ _("Sorry, can not open the software database"),
102+ _("Please re-install the 'software-center' "
103+ "package."))
104+ # FIXME: force rebuild by providing a dbus service for this
105+ sys.exit(1)
106
107 # additional icons come from app-install-data
108- self.icons = get_sc_icon_theme(self.datadir)
109+ with ExecutionTime("building the icon cache"):
110+ self.icons = get_sc_icon_theme(self.datadir)
111
112 # backend
113- self.backend = get_install_backend()
114- self.backend.ui = InstallBackendUI()
115- self.backend.connect("transaction-finished", self._on_transaction_finished)
116- self.backend.connect("channels-changed", self.on_channels_changed)
117+ with ExecutionTime("creating the backend"):
118+ self.backend = get_install_backend()
119+ self.backend.ui = InstallBackendUI()
120+ self.backend.connect("transaction-finished", self._on_transaction_finished)
121+ self.backend.connect("channels-changed", self.on_channels_changed)
122
123 # high level app management
124- self.app_manager = ApplicationManager(self.db, self.backend, self.icons)
125+ with ExecutionTime("get the app-manager"):
126+ self.app_manager = ApplicationManager(self.db, self.backend, self.icons)
127
128 # misc state
129 self._block_menuitem_view = False
130@@ -276,43 +281,45 @@
131 datadir)
132
133 # register view manager and create view panes/widgets
134- self.view_manager = ViewManager(self.notebook_view, options)
135-
136- self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons)
137- self.vbox1.pack_start(self.global_pane, False, False, 0)
138- self.vbox1.reorder_child(self.global_pane, 1)
139-
140- # available pane
141- self.available_pane = AvailablePane(self.cache,
142+ with ExecutionTime("ViewManager"):
143+ self.view_manager = ViewManager(self.notebook_view, options)
144+
145+ with ExecutionTime("building panes"):
146+ self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons)
147+ self.vbox1.pack_start(self.global_pane, False, False, 0)
148+ self.vbox1.reorder_child(self.global_pane, 1)
149+
150+ # available pane
151+ self.available_pane = AvailablePane(self.cache,
152+ self.db,
153+ self.distro,
154+ self.icons,
155+ self.datadir,
156+ self.navhistory_back_action,
157+ self.navhistory_forward_action)
158+ self.available_pane.connect("available-pane-created", self.on_available_pane_created)
159+ self.view_manager.register(self.available_pane, ViewPages.AVAILABLE)
160+
161+ # installed pane (view not fully initialized at this point)
162+ self.installed_pane = InstalledPane(self.cache,
163+ self.db,
164+ self.distro,
165+ self.icons,
166+ self.datadir)
167+ #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created)
168+ self.view_manager.register(self.installed_pane, ViewPages.INSTALLED)
169+
170+ # history pane (not fully loaded at this point)
171+ self.history_pane = HistoryPane(self.cache,
172 self.db,
173 self.distro,
174 self.icons,
175- self.datadir,
176- self.navhistory_back_action,
177- self.navhistory_forward_action)
178- self.available_pane.connect("available-pane-created", self.on_available_pane_created)
179- self.view_manager.register(self.available_pane, ViewPages.AVAILABLE)
180-
181- # installed pane (view not fully initialized at this point)
182- self.installed_pane = InstalledPane(self.cache,
183- self.db,
184- self.distro,
185- self.icons,
186 self.datadir)
187- #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created)
188- self.view_manager.register(self.installed_pane, ViewPages.INSTALLED)
189-
190- # history pane (not fully loaded at this point)
191- self.history_pane = HistoryPane(self.cache,
192- self.db,
193- self.distro,
194- self.icons,
195- self.datadir)
196- self.view_manager.register(self.history_pane, ViewPages.HISTORY)
197-
198- # pending pane
199- self.pending_pane = PendingPane(self.icons)
200- self.view_manager.register(self.pending_pane, ViewPages.PENDING)
201+ self.view_manager.register(self.history_pane, ViewPages.HISTORY)
202+
203+ # pending pane
204+ self.pending_pane = PendingPane(self.icons)
205+ self.view_manager.register(self.pending_pane, ViewPages.PENDING)
206
207 # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help
208 self.menuitem_help.set_label(_("%s _Help")%self.distro.get_app_name())
209@@ -321,16 +328,18 @@
210 self.window_main.set_size_request(730, 470)
211
212 # reviews
213- self.review_loader = get_review_loader(self.cache, self.db)
214- # FIXME: add some kind of throttle, I-M-S here
215- self.review_loader.refresh_review_stats(self.on_review_stats_loaded)
216- #load usefulness votes from server when app starts
217- self.useful_cache = UsefulnessCache(True)
218- self.setup_database_rebuilding_listener()
219+ with ExecutionTime("create review loader"):
220+ self.review_loader = get_review_loader(self.cache, self.db)
221+ # FIXME: add some kind of throttle, I-M-S here
222+ self.review_loader.refresh_review_stats(self.on_review_stats_loaded)
223+ #load usefulness votes from server when app starts
224+ self.useful_cache = UsefulnessCache(True)
225+ self.setup_database_rebuilding_listener()
226
227- # open plugin manager and load plugins
228- self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
229- self.plugin_manager.load_plugins()
230+ with ExecutionTime("create plugin manager"):
231+ # open plugin manager and load plugins
232+ self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS)
233+ self.plugin_manager.load_plugins()
234
235 # setup window name and about information (needs branding)
236 name = self.distro.get_app_name()
237@@ -384,13 +393,14 @@
238 if not (options.enable_lp or och):
239 file_menu.remove(self.builder.get_object("separator_login"))
240 else:
241- sc_agent_update = os.path.join(
242- self.datadir, "update-software-center-agent")
243- (pid, stdin, stdout, stderr) = GObject.spawn_async(
244- [sc_agent_update, "--datadir", datadir],
245- flags=GObject.SPAWN_DO_NOT_REAP_CHILD)
246- GObject.child_watch_add(
247- pid, self._on_update_software_center_agent_finished)
248+ with ExecutionTime("run update-software-center-agent"):
249+ sc_agent_update = os.path.join(
250+ self.datadir, "update-software-center-agent")
251+ (pid, stdin, stdout, stderr) = GObject.spawn_async(
252+ [sc_agent_update, "--datadir", datadir],
253+ flags=GObject.SPAWN_DO_NOT_REAP_CHILD)
254+ GObject.child_watch_add(
255+ pid, self._on_update_software_center_agent_finished)
256
257 # TODO: Remove the following two lines once we have remove repository
258 # support in aptdaemon (see LP: #723911)
259@@ -1223,4 +1233,3 @@
260 self.show_available_packages(args)
261
262 atexit.register(self.save_state)
263- SimpleGtkbuilderApp.run(self)

Subscribers

People subscribed via source and target branches