Merge lp:~mvo/software-center/performance-probes into lp:software-center
- performance-probes
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gary Lasker (community) | Approve | ||
Michael Vogt | Pending | ||
Review via email: mp+85745@code.launchpad.net |
Commit message
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.
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 | 135 | # DEBUG/PROFILE mode | 135 | # DEBUG/PROFILE mode |
6 | 136 | if options.measure_startup_time: | 136 | if options.measure_startup_time: |
7 | 137 | with ExecutionTime("show() & gtk events until visible"): | 137 | with ExecutionTime("show() & gtk events until visible"): |
16 | 138 | # app.window_main.show_all() | 138 | app.run(args) |
17 | 139 | while Gtk.events_pending(): | 139 | while not (app.available_pane.cat_view and |
18 | 140 | # test visible area | 140 | app.available_pane.cat_view.get_visible()): |
19 | 141 | if (app.window_main.get_visible() and | 141 | while Gtk.events_pending(): |
20 | 142 | app.available_pane.searchentry.get_visible() and | 142 | Gtk.main_iteration() |
13 | 143 | app.available_pane.back_forward.get_visible): | ||
14 | 144 | break | ||
15 | 145 | Gtk.main_iteration() | ||
21 | 146 | time_to_visible = time.time() - time_entering_main | 143 | time_to_visible = time.time() - time_entering_main |
22 | 147 | print(time_to_visible) | 144 | print(time_to_visible) |
23 | 148 | sys.exit(0) | 145 | sys.exit(0) |
24 | 149 | 146 | ||
25 | 150 | # run it normally | 147 | # run it normally |
26 | 151 | app.run(args) | 148 | app.run(args) |
27 | 149 | Gtk.main() | ||
28 | 152 | 150 | ||
29 | 153 | 151 | ||
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 | 62 | from softwarecenter.utils import (clear_token_from_ubuntu_sso, | 62 | from softwarecenter.utils import (clear_token_from_ubuntu_sso, |
35 | 63 | get_http_proxy_string_from_gsettings, | 63 | get_http_proxy_string_from_gsettings, |
36 | 64 | wait_for_apt_cache_ready, | 64 | wait_for_apt_cache_ready, |
37 | 65 | ExecutionTime, | ||
38 | 65 | is_unity_running) | 66 | is_unity_running) |
39 | 66 | from softwarecenter.ui.gtk3.utils import (get_sc_icon_theme, | 67 | from softwarecenter.ui.gtk3.utils import (get_sc_icon_theme, |
40 | 67 | init_sc_css_provider) | 68 | init_sc_css_provider) |
41 | @@ -209,49 +210,53 @@ | |||
42 | 209 | sources = self.builder.get_object("menuitem_software_sources") | 210 | sources = self.builder.get_object("menuitem_software_sources") |
43 | 210 | sources.set_sensitive(False) | 211 | sources.set_sensitive(False) |
44 | 211 | 212 | ||
49 | 212 | # a main iteration friendly apt cache | 213 | with ExecutionTime("opening the pkginfo"): |
50 | 213 | self.cache = get_pkg_info() | 214 | # a main iteration friendly apt cache |
51 | 214 | self.cache.open() | 215 | self.cache = get_pkg_info() |
52 | 215 | self.cache.connect("cache-broken", self._on_apt_cache_broken) | 216 | self.cache.open() |
53 | 217 | self.cache.connect("cache-broken", self._on_apt_cache_broken) | ||
54 | 216 | 218 | ||
65 | 217 | # xapian | 219 | with ExecutionTime("opening the xapiandb"): |
66 | 218 | pathname = os.path.join(xapian_base_path, "xapian") | 220 | pathname = os.path.join(xapian_base_path, "xapian") |
67 | 219 | self._use_axi = not options.disable_apt_xapian_index | 221 | self._use_axi = not options.disable_apt_xapian_index |
68 | 220 | try: | 222 | try: |
69 | 221 | self.db = StoreDatabase(pathname, self.cache) | 223 | self.db = StoreDatabase(pathname, self.cache) |
70 | 222 | self.db.open(use_axi = self._use_axi) | 224 | self.db.open(use_axi = self._use_axi) |
71 | 223 | if self.db.schema_version() != DB_SCHEMA_VERSION: | 225 | if self.db.schema_version() != DB_SCHEMA_VERSION: |
72 | 224 | LOG.warn("database format '%s' expected, but got '%s'" % ( | 226 | LOG.warn("database format '%s' expected, but got '%s'" % ( |
73 | 225 | DB_SCHEMA_VERSION, self.db.schema_version())) | 227 | DB_SCHEMA_VERSION, self.db.schema_version())) |
74 | 226 | if os.access(pathname, os.W_OK): | 228 | if os.access(pathname, os.W_OK): |
75 | 229 | self._rebuild_and_reopen_local_db(pathname) | ||
76 | 230 | except xapian.DatabaseOpeningError: | ||
77 | 231 | # Couldn't use that folder as a database | ||
78 | 232 | # This may be because we are in a bzr checkout and that | ||
79 | 233 | # folder is empty. If the folder is empty, and we can find the | ||
80 | 234 | # script that does population, populate a database in it. | ||
81 | 235 | if os.path.isdir(pathname) and not os.listdir(pathname): | ||
82 | 227 | self._rebuild_and_reopen_local_db(pathname) | 236 | self._rebuild_and_reopen_local_db(pathname) |
98 | 228 | except xapian.DatabaseOpeningError: | 237 | except xapian.DatabaseCorruptError: |
99 | 229 | # Couldn't use that folder as a database | 238 | LOG.exception("xapian open failed") |
100 | 230 | # This may be because we are in a bzr checkout and that | 239 | dialogs.error(None, |
101 | 231 | # folder is empty. If the folder is empty, and we can find the | 240 | _("Sorry, can not open the software database"), |
102 | 232 | # script that does population, populate a database in it. | 241 | _("Please re-install the 'software-center' " |
103 | 233 | if os.path.isdir(pathname) and not os.listdir(pathname): | 242 | "package.")) |
104 | 234 | self._rebuild_and_reopen_local_db(pathname) | 243 | # FIXME: force rebuild by providing a dbus service for this |
105 | 235 | except xapian.DatabaseCorruptError: | 244 | sys.exit(1) |
91 | 236 | LOG.exception("xapian open failed") | ||
92 | 237 | dialogs.error(None, | ||
93 | 238 | _("Sorry, can not open the software database"), | ||
94 | 239 | _("Please re-install the 'software-center' " | ||
95 | 240 | "package.")) | ||
96 | 241 | # FIXME: force rebuild by providing a dbus service for this | ||
97 | 242 | sys.exit(1) | ||
106 | 243 | 245 | ||
107 | 244 | # additional icons come from app-install-data | 246 | # additional icons come from app-install-data |
109 | 245 | self.icons = get_sc_icon_theme(self.datadir) | 247 | with ExecutionTime("building the icon cache"): |
110 | 248 | self.icons = get_sc_icon_theme(self.datadir) | ||
111 | 246 | 249 | ||
112 | 247 | # backend | 250 | # backend |
117 | 248 | self.backend = get_install_backend() | 251 | with ExecutionTime("creating the backend"): |
118 | 249 | self.backend.ui = InstallBackendUI() | 252 | self.backend = get_install_backend() |
119 | 250 | self.backend.connect("transaction-finished", self._on_transaction_finished) | 253 | self.backend.ui = InstallBackendUI() |
120 | 251 | self.backend.connect("channels-changed", self.on_channels_changed) | 254 | self.backend.connect("transaction-finished", self._on_transaction_finished) |
121 | 255 | self.backend.connect("channels-changed", self.on_channels_changed) | ||
122 | 252 | 256 | ||
123 | 253 | # high level app management | 257 | # high level app management |
125 | 254 | self.app_manager = ApplicationManager(self.db, self.backend, self.icons) | 258 | with ExecutionTime("get the app-manager"): |
126 | 259 | self.app_manager = ApplicationManager(self.db, self.backend, self.icons) | ||
127 | 255 | 260 | ||
128 | 256 | # misc state | 261 | # misc state |
129 | 257 | self._block_menuitem_view = False | 262 | self._block_menuitem_view = False |
130 | @@ -276,43 +281,45 @@ | |||
131 | 276 | datadir) | 281 | datadir) |
132 | 277 | 282 | ||
133 | 278 | # register view manager and create view panes/widgets | 283 | # register view manager and create view panes/widgets |
142 | 279 | self.view_manager = ViewManager(self.notebook_view, options) | 284 | with ExecutionTime("ViewManager"): |
143 | 280 | 285 | self.view_manager = ViewManager(self.notebook_view, options) | |
144 | 281 | self.global_pane = GlobalPane(self.view_manager, self.datadir, self.db, self.cache, self.icons) | 286 | |
145 | 282 | self.vbox1.pack_start(self.global_pane, False, False, 0) | 287 | with ExecutionTime("building panes"): |
146 | 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) |
147 | 284 | 289 | self.vbox1.pack_start(self.global_pane, False, False, 0) | |
148 | 285 | # available pane | 290 | self.vbox1.reorder_child(self.global_pane, 1) |
149 | 286 | self.available_pane = AvailablePane(self.cache, | 291 | |
150 | 292 | # available pane | ||
151 | 293 | self.available_pane = AvailablePane(self.cache, | ||
152 | 294 | self.db, | ||
153 | 295 | self.distro, | ||
154 | 296 | self.icons, | ||
155 | 297 | self.datadir, | ||
156 | 298 | self.navhistory_back_action, | ||
157 | 299 | self.navhistory_forward_action) | ||
158 | 300 | self.available_pane.connect("available-pane-created", self.on_available_pane_created) | ||
159 | 301 | self.view_manager.register(self.available_pane, ViewPages.AVAILABLE) | ||
160 | 302 | |||
161 | 303 | # installed pane (view not fully initialized at this point) | ||
162 | 304 | self.installed_pane = InstalledPane(self.cache, | ||
163 | 305 | self.db, | ||
164 | 306 | self.distro, | ||
165 | 307 | self.icons, | ||
166 | 308 | self.datadir) | ||
167 | 309 | #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created) | ||
168 | 310 | self.view_manager.register(self.installed_pane, ViewPages.INSTALLED) | ||
169 | 311 | |||
170 | 312 | # history pane (not fully loaded at this point) | ||
171 | 313 | self.history_pane = HistoryPane(self.cache, | ||
172 | 287 | self.db, | 314 | self.db, |
173 | 288 | self.distro, | 315 | self.distro, |
174 | 289 | self.icons, | 316 | self.icons, |
175 | 290 | self.datadir, | ||
176 | 291 | self.navhistory_back_action, | ||
177 | 292 | self.navhistory_forward_action) | ||
178 | 293 | self.available_pane.connect("available-pane-created", self.on_available_pane_created) | ||
179 | 294 | self.view_manager.register(self.available_pane, ViewPages.AVAILABLE) | ||
180 | 295 | |||
181 | 296 | # installed pane (view not fully initialized at this point) | ||
182 | 297 | self.installed_pane = InstalledPane(self.cache, | ||
183 | 298 | self.db, | ||
184 | 299 | self.distro, | ||
185 | 300 | self.icons, | ||
186 | 301 | self.datadir) | 317 | self.datadir) |
201 | 302 | #~ self.installed_pane.connect("installed-pane-created", self.on_installed_pane_created) | 318 | self.view_manager.register(self.history_pane, ViewPages.HISTORY) |
202 | 303 | self.view_manager.register(self.installed_pane, ViewPages.INSTALLED) | 319 | |
203 | 304 | 320 | # pending pane | |
204 | 305 | # history pane (not fully loaded at this point) | 321 | self.pending_pane = PendingPane(self.icons) |
205 | 306 | self.history_pane = HistoryPane(self.cache, | 322 | self.view_manager.register(self.pending_pane, ViewPages.PENDING) |
192 | 307 | self.db, | ||
193 | 308 | self.distro, | ||
194 | 309 | self.icons, | ||
195 | 310 | self.datadir) | ||
196 | 311 | self.view_manager.register(self.history_pane, ViewPages.HISTORY) | ||
197 | 312 | |||
198 | 313 | # pending pane | ||
199 | 314 | self.pending_pane = PendingPane(self.icons) | ||
200 | 315 | self.view_manager.register(self.pending_pane, ViewPages.PENDING) | ||
206 | 316 | 323 | ||
207 | 317 | # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help | 324 | # TRANSLATORS: this is the help menuitem label, e.g. Ubuntu Software Center _Help |
208 | 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()) |
209 | @@ -321,16 +328,18 @@ | |||
210 | 321 | self.window_main.set_size_request(730, 470) | 328 | self.window_main.set_size_request(730, 470) |
211 | 322 | 329 | ||
212 | 323 | # reviews | 330 | # reviews |
219 | 324 | self.review_loader = get_review_loader(self.cache, self.db) | 331 | with ExecutionTime("create review loader"): |
220 | 325 | # FIXME: add some kind of throttle, I-M-S here | 332 | self.review_loader = get_review_loader(self.cache, self.db) |
221 | 326 | self.review_loader.refresh_review_stats(self.on_review_stats_loaded) | 333 | # FIXME: add some kind of throttle, I-M-S here |
222 | 327 | #load usefulness votes from server when app starts | 334 | self.review_loader.refresh_review_stats(self.on_review_stats_loaded) |
223 | 328 | self.useful_cache = UsefulnessCache(True) | 335 | #load usefulness votes from server when app starts |
224 | 329 | self.setup_database_rebuilding_listener() | 336 | self.useful_cache = UsefulnessCache(True) |
225 | 337 | self.setup_database_rebuilding_listener() | ||
226 | 330 | 338 | ||
230 | 331 | # open plugin manager and load plugins | 339 | with ExecutionTime("create plugin manager"): |
231 | 332 | self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS) | 340 | # open plugin manager and load plugins |
232 | 333 | self.plugin_manager.load_plugins() | 341 | self.plugin_manager = PluginManager(self, SOFTWARE_CENTER_PLUGIN_DIRS) |
233 | 342 | self.plugin_manager.load_plugins() | ||
234 | 334 | 343 | ||
235 | 335 | # setup window name and about information (needs branding) | 344 | # setup window name and about information (needs branding) |
236 | 336 | name = self.distro.get_app_name() | 345 | name = self.distro.get_app_name() |
237 | @@ -384,13 +393,14 @@ | |||
238 | 384 | if not (options.enable_lp or och): | 393 | if not (options.enable_lp or och): |
239 | 385 | file_menu.remove(self.builder.get_object("separator_login")) | 394 | file_menu.remove(self.builder.get_object("separator_login")) |
240 | 386 | else: | 395 | else: |
248 | 387 | sc_agent_update = os.path.join( | 396 | with ExecutionTime("run update-software-center-agent"): |
249 | 388 | self.datadir, "update-software-center-agent") | 397 | sc_agent_update = os.path.join( |
250 | 389 | (pid, stdin, stdout, stderr) = GObject.spawn_async( | 398 | self.datadir, "update-software-center-agent") |
251 | 390 | [sc_agent_update, "--datadir", datadir], | 399 | (pid, stdin, stdout, stderr) = GObject.spawn_async( |
252 | 391 | flags=GObject.SPAWN_DO_NOT_REAP_CHILD) | 400 | [sc_agent_update, "--datadir", datadir], |
253 | 392 | GObject.child_watch_add( | 401 | flags=GObject.SPAWN_DO_NOT_REAP_CHILD) |
254 | 393 | pid, self._on_update_software_center_agent_finished) | 402 | GObject.child_watch_add( |
255 | 403 | pid, self._on_update_software_center_agent_finished) | ||
256 | 394 | 404 | ||
257 | 395 | # TODO: Remove the following two lines once we have remove repository | 405 | # TODO: Remove the following two lines once we have remove repository |
258 | 396 | # support in aptdaemon (see LP: #723911) | 406 | # support in aptdaemon (see LP: #723911) |
259 | @@ -1223,4 +1233,3 @@ | |||
260 | 1223 | self.show_available_packages(args) | 1233 | self.show_available_packages(args) |
261 | 1224 | 1234 | ||
262 | 1225 | atexit.register(self.save_state) | 1235 | atexit.register(self.save_state) |
263 | 1226 | SimpleGtkbuilderApp.run(self) |
Looks good, thanks mvo!