After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 687911 - Focused/Unfocused theming applied slowly
Focused/Unfocused theming applied slowly
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: Contact List
3.6.x
Other Linux
: Normal normal
: 3.6
Assigned To: empathy-maint
empathy-maint
: 687536 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-11-08 11:20 UTC by Lionel Landwerlin
Modified: 2012-12-28 13:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add big contact list test case (4.42 KB, patch)
2012-11-08 12:22 UTC, Xavier Claessens
none Details | Review
Callgrind logs when doing a focus in/out (775.35 KB, application/octet-stream)
2012-11-08 13:17 UTC, Xavier Claessens
  Details
Use a pixbuf cache (4.32 KB, patch)
2012-11-08 17:06 UTC, Xavier Claessens
none Details | Review
The new callgrind logs (467.38 KB, application/octet-stream)
2012-11-08 17:10 UTC, Xavier Claessens
  Details
screenshot of the interesting part of callgrind (400.64 KB, image/png)
2012-11-08 17:11 UTC, Xavier Claessens
  Details
Self contained test case (3.93 KB, text/x-csrc)
2012-11-09 11:09 UTC, Xavier Claessens
  Details

Description Lionel Landwerlin 2012-11-08 11:20:47 UTC
On Gnome 3.6 when moving the focus from the empathy chat window to the contact list window, it takes about 1s to change the theme on the contact list window (from unfocused to focused.

If you try to click back and forth between these 2 window and look at the CPU consumption through top, the empathy process (which manages the contact list window) appears to consume 98% of cpu (vs just 20% for the empathy-chat process).

If I disconnect one of my jabber accounts (which has about 80 contacts), then the performances become acceptable again.
Comment 1 Guillaume Desmottes 2012-11-08 11:23:46 UTC
Indeed, it's pretty slow here as well. I suspect that's the code changing the widget look when unfocussed which isn't playing nice with EggListBox or something.
Comment 2 Xavier Claessens 2012-11-08 12:22:52 UTC
Created attachment 228463 [details] [review]
Add big contact list test case

Focus in/out this window used to take a lot of CPU. See
https://bugzilla.gnome.org/show_bug.cgi?id=687911

The dummy row widget code is copied from empathy-roster-contact.c to
make the test more realistic.
Comment 3 Xavier Claessens 2012-11-08 13:17:40 UTC
Created attachment 228465 [details]
Callgrind logs when doing a focus in/out

I'm reading that file with kcachegrind. It looks like all of the CPU goes into calculating the width of widgets.
Comment 4 Alexander Larsson 2012-11-08 14:09:50 UTC
Analysis:

Slowness is caused by all widgets changing style when going to the unfocused state causing style_update() emissions on all widgets. Plus:

GtkLabel: always clears all PangoLayouts on any style change even if it doesn't affect the layout (i.e. a color change) => 1000s of PangoLayout measures is slow.

GtkImage: Always clears the pixbuf on any style change => reloads the icon files 1000s of time, which is slow
Comment 5 Lionel Landwerlin 2012-11-08 14:13:13 UTC
Isn't the contact list a GtkTreeView?
Comment 6 Xavier Claessens 2012-11-08 14:20:38 UTC
@Lionel: not anymore, it is now using EggListBox which is probably going into GTK at some point. It's much nicer API, it's just a vbox basically :-)
Comment 7 Lionel Landwerlin 2012-11-08 15:03:56 UTC
I can't see any font size change on the contact list, only a color change. It should be possible to optimize that case to avoid relayouting.

When you create a GtkImage with a given GdkPixbuf, the theme shouldn't clean the pixbuf since it's not related to the theme anymore.

Are these optimization realistic?
Comment 8 Xavier Claessens 2012-11-08 17:06:25 UTC
Created attachment 228489 [details] [review]
Use a pixbuf cache
Comment 9 Xavier Claessens 2012-11-08 17:09:57 UTC
Here is an attempt to workaround the problem in the test case. It indeed makes things faster, but still not perfect IMHO.

With that patch, the size calculation related functions are down to 2% of CPU. But now it is _gtk_style_context_validate() which takes 88% of the time, which is less surprising since changing the style context is what it is supposed to be doing.
Comment 10 Xavier Claessens 2012-11-08 17:10:39 UTC
Created attachment 228490 [details]
The new callgrind logs
Comment 11 Xavier Claessens 2012-11-08 17:11:18 UTC
Created attachment 228491 [details]
screenshot of the interesting part of callgrind
Comment 12 Alexander Larsson 2012-11-09 09:19:36 UTC
I pushed some optimizations to gtk git master to make this somewhat faster. Its still as slow for images/labels though.
Comment 13 Xavier Claessens 2012-11-09 11:09:45 UTC
Created attachment 228546 [details]
Self contained test case

Here is a test case program that uses only GTK and not EggListBox. It has a boolean to switch on image cache hack to demonstrate that it speed it up a lot already.
Comment 14 Alexander Larsson 2012-12-10 15:50:16 UTC
This is working much better in Gtk+ master, as i spent a bunch of time optimizing CSS matching.
Comment 15 Guillaume Desmottes 2012-12-28 13:17:00 UTC
*** Bug 687536 has been marked as a duplicate of this bug. ***