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 765284 - debug: reduce runtime overhead in debug builds
debug: reduce runtime overhead in debug builds
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-04-20 02:38 UTC by Christian Hergert
Modified: 2016-04-20 03:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
debug: avoid GQuark and GData usage in gtk_get_debug_flags() (1.94 KB, patch)
2016-04-20 02:38 UTC, Christian Hergert
none Details | Review
debug: remove open-coded debug checks in gtktextsegment (2.62 KB, patch)
2016-04-20 02:38 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2016-04-20 02:38:42 UTC
This only affects debug builds, but we do spend a lot of the cycle running
debug builds. So speeding this up makes it easier to focus on other things
that change runtime performance.

The g_object_get_data() combined with the quark lookup (and associated
bit locks) was accounting for about 7% of the collected callchains when
sampling GtkSourceView performance. With this patch we are down to less
than .5%. That is a much more acceptable overhead for debug runtime
checks.

Additionally, we remove the open-coded debug checks in gtktextsegment
in favor of our compile-time conditional debug check macro.
Comment 1 Christian Hergert 2016-04-20 02:38:45 UTC
Created attachment 326364 [details] [review]
debug: avoid GQuark and GData usage in gtk_get_debug_flags()

This only affects debug builds, but we do spend a lot of the cycle running
debug builds. So speeding this up makes it easier to focus on other things
that change runtime performance.

The g_object_get_data() combined with the quark lookup (and associated
bit locks) was accounting for about 7% of the collected callchains when
sampling GtkSourceView performance. With this patch we are down to less
than .5%. That is a much more acceptable overhead for debug runtime
checks.
Comment 2 Christian Hergert 2016-04-20 02:38:50 UTC
Created attachment 326365 [details] [review]
debug: remove open-coded debug checks in gtktextsegment

These runtime checks were being performed whether or not we were in a
debug build. Using GTK_DEBUG_CHECK() will compile out of production
builds, as it will result in something like:

  if (G_UNLIKELY(0))

which the optimizer can prune.
Comment 3 Matthias Clasen 2016-04-20 02:50:42 UTC
I appreciate the performance win, but storing gtk debug flags in gdk structures seems wrong to me.
Comment 4 Matthias Clasen 2016-04-20 02:52:01 UTC
Review of attachment 326365 [details] [review]:

this looks fine to me
Comment 5 Christian Hergert 2016-04-20 02:59:42 UTC
(In reply to Matthias Clasen from comment #3)
> I appreciate the performance win, but storing gtk debug flags in gdk
> structures seems wrong to me.

I had the same feeling, but having debug flags per-display seemed a bit strange too. I take it that is something we use the inspector for?

Any other ideas for where to stash it?
Comment 6 Matthias Clasen 2016-04-20 03:28:20 UTC
We want to avoid visual debugging flags affecting the inspector, which is why we scope them to the display (the inspector has its own display connection).

I've pushed a few fixes to reduce the cost a bit.
Comment 7 Christian Hergert 2016-04-20 03:43:24 UTC
Seems good enough. It gets things down to about ~3% due to the type check.