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 765640 - pixelcache: reuse existing timeout source when possible
pixelcache: reuse existing timeout source when possible
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-26 21:59 UTC by Christian Hergert
Modified: 2016-04-27 10:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pixelcache: reuse existing timeout source when possible (2.22 KB, patch)
2016-04-26 21:59 UTC, Christian Hergert
none Details | Review
pixelcache: reuse existing timeout source when possible (4.05 KB, patch)
2016-04-27 02:30 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2016-04-26 21:59:12 UTC
This cuts some time out of all pixelcache backed widgets (TextView,
TreeView, Viewport, etc) during scrolling since we can re-use the
previous source.
Comment 1 Christian Hergert 2016-04-26 21:59:16 UTC
Created attachment 326810 [details] [review]
pixelcache: reuse existing timeout source when possible

First off, this might seem like a layer violation simply because we
know that it is a timeout source and that the timeout source uses
the ready time to fire. But that couldn't really change without a
break in GLib, so it seems perfectly fine to rely on it.

This avoids the g_source_remove(), g_source_destroy(),
g_timer_source_new(), and g_source_set_name_by_id() in the common case.

Instead, we reuse our previous source and update the ready time to our
new deadline. We lose the coalescing with g_timeout_add_seconds(), but
that is not going to help in the common case anyway (unless you have
three hands and can scroll multiple pixelcached backed widgets at once).
Comment 2 Matthias Clasen 2016-04-27 02:22:10 UTC
Review of attachment 326810 [details] [review]:

::: gtk/gtkpixelcache.c
@@ +449,2 @@
+      deadline = g_get_monotonic_time () + (BLOW_CACHE_TIMEOUT_SEC * G_USEC_PER_SEC);
+      source = g_main_context_find_source_by_id (NULL, cache->timeout_tag);

if you go to this length, why not go all the way: keep the source pointer instead of the tag, and avoid the find-by-id ?
Comment 3 Christian Hergert 2016-04-27 02:30:51 UTC
Created attachment 326823 [details] [review]
pixelcache: reuse existing timeout source when possible

This avoids the g_source_remove(), g_source_destroy(),
g_timer_source_new(), and g_source_set_name_by_id() in the common case.

Instead, we reuse our previous source and update the ready time to our
new deadline. We lose the coalescing with g_timeout_add_seconds(), but
that is not going to help in the common case anyway (unless you have
three hands and can scroll multiple pixelcached backed widgets at once).
Comment 4 Christian Hergert 2016-04-27 02:32:23 UTC
I was trying to be a little bit too minimal in the patch! This caches the GSource instead as suggested.

While I was there, I cleaned up a couple other open coded pointer check/frees.
Comment 5 Matthias Clasen 2016-04-27 10:27:09 UTC
Attachment 326823 [details] pushed as 0763a02 - pixelcache: reuse existing timeout source when possible