DBus menu is very slow when using large menu

Bug #801699 reported by Evan Martin (Chromium) on 2011-06-24
90
This bug affects 18 people
Affects Status Importance Assigned to Milestone
DBus Menu
Fix Released
Medium
Ted Gould
libdbusmenu (Ubuntu)
Undecided
Unassigned

Bug Description

Chrome tries to expose the user's bookmarks via GTK. We found that our app startup could take multiple minutes (!) for users that had a lot of bookmarks.

http://code.google.com/p/chromium/issues/detail?id=86715
http://code.google.com/p/chromium/issues/detail?id=85466

Some more technical details: because we have a weird custom menu, what we do is build a hidden GtkMenu that we insert all of our bookmarks in. The call stack when the code is hung looks like this:

Thread 1 (Thread 0xb62bb870 (LWP 31589)):
#0 0xb6f5307e in ?? () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#1 0xb6f4fb53 in g_value_init () from /usr/lib/i386-linux-gnu/libgobject-2.0.so.0
#2 0xaf66d70e in dbusmenu_menuitem_get_id () from /usr/lib/libdbusmenu-glib.so.3
#3 0xaf66d9c6 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#4 0xb6e7a1a9 in g_list_foreach () from /lib/i386-linux-gnu/libglib-2.0.so.0
#5 0xaf66d9e9 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#6 0xb6e7a1a9 in g_list_foreach () from /lib/i386-linux-gnu/libglib-2.0.so.0
#7 0xaf66d9e9 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#8 0xb6e7a1a9 in g_list_foreach () from /lib/i386-linux-gnu/libglib-2.0.so.0
#9 0xaf66d9e9 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#10 0xb6e7a1a9 in g_list_foreach () from /lib/i386-linux-gnu/libglib-2.0.so.0
#11 0xaf66d9e9 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#12 0xb6e7a1a9 in g_list_foreach () from /lib/i386-linux-gnu/libglib-2.0.so.0
#13 0xaf66d9e9 in ?? () from /usr/lib/libdbusmenu-glib.so.3
#14 0xaf66f901 in dbusmenu_menuitem_find_id () from /usr/lib/libdbusmenu-glib.so.3
#15 0xaf67241b in ?? () from /usr/lib/libdbusmenu-glib.so.3
#16 0xaf672e3d in ?? () from /usr/lib/libdbusmenu-glib.so.3
#17 0xb66c85b2 in ?? () from /usr/lib/i386-linux-gnu/libgio-2.0.so.0
#18 0xb6e7a311 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#19 0xb6e7eaa8 in g_main_context_dispatch () from /lib/i386-linux-gnu/libglib-2.0.so.0
#20 0xb6e7f270 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
#21 0xb6e7f524 in g_main_context_iteration () from /lib/i386-linux-gnu/libglib-2.0.so.0
#22 0x0879f259 in base::MessagePumpForUI::RunOnce

We're going to disable this code for now. We'll put the bookmarks menu code behind a flag, so that you can test any fixes to this bug against trunk Chrome by running with that flag, and once this code is performant we'll reenable it. In general, it's really bad for startup performance to put this in the critical path of startup; it'd be nice if we could do this on a background thread.

Related branches

Ted Gould (ted) on 2011-06-24
Changed in dbusmenu:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Ted Gould (ted)
Elliot Glaysher (glaysher) wrote :

I don't have a Natty install at the moment, but I'll point out that depending on disk contention, the bookmark menu code can potentially send two 16x16 icons for each bookmark menu item (set default favicon since favicon database hasn't async loaded yet, set the real favicon after database).

So for 100 bookmarks * 16x16 icon * 4 bytes a pixel is 800kb for one pass, 1.5 megs for both passes. Is that a problem for dbus?

Ajay Roopakalu (ajay-roopakalu) wrote :

My Chrome is affected by this bug.

I ran dbusmenu-dumper on the hanging Chrome process (I don't want to attach the file for privacy reasons since all my bookmarks are listed) and it outputted a file that was over 65k lines of JSON.

Ted Gould (ted) wrote :

Could you please attach a JSON dump of the menus that cause this bug? It would help greatly with debugging it. To do that you'll need to install libdbusmenu-tools package and run /usr/lib/libdbusmenu/dbusmenu-dumper. You can then click on the window of the menus. Thanks!

Elliot Glaysher (glaysher) wrote :

In chrome, we're fixing this by removing all icons from the History menu and the Bookmarks menu in its entirety. (This doesn't mean we're abandoning the rest of the global menu.)

In general, I mirror Evan's comment that it'd be nice if this wasn't in the critical path.

Chris Coulson (chrisccoulson) wrote :

This hits Firefox really hard as well now in Precise, now that the HUD is asking for the whole menu structure at once. I did a rough test, and it takes roughly a minute of CPU for 8000 bookmarks (arranged 20*20*20)

On Tue, 2012-03-27 at 01:37 +0000, Chris Coulson wrote:
> This hits Firefox really hard as well now in Precise, now that the HUD
> is asking for the whole menu structure at once. I did a rough test, and
> it takes roughly a minute of CPU for 8000 bookmarks (arranged 20*20*20)

Can you attach a dbus-menu-dumper output of that to the bug? That way
we can use it for a test.

Chris Coulson (chrisccoulson) wrote :

Here we go - it's quite big! This contains around 8000 bookmarks or so

Charles Kerr (charlesk) wrote :

Chris' awesome hash cache patch has landed and will be in this week's release.

Chris Coulson (chrisccoulson) wrote :

This is in precise now

Changed in libdbusmenu (Ubuntu):
status: New → Fix Released
Chris Coulson (chrisccoulson) wrote :

Evan / Elliot - is there still a flag for enabling the bookmark menu in Chrome?

Charles Kerr (charlesk) on 2012-04-03
Changed in dbusmenu:
status: Triaged → Fix Committed
Greg A (etulfetulf) wrote :

The code has been removed from Chrome: http://codereview.chromium.org/8293002

Ted Gould (ted) on 2012-09-25
Changed in dbusmenu:
status: Fix Committed → Fix Released

It seems to be still here in Ubuntu 12.10, or am I wrong?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments