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 426924 - gtk_widget_get_draw_rectangle() very slow for big containers
gtk_widget_get_draw_rectangle() very slow for big containers
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.10.x
Other Linux
: Normal normal
: 3.0
Assigned To: gtk-bugs
gtk-bugs
deprecations
Depends on:
Blocks:
 
 
Reported: 2007-04-06 13:50 UTC by Jorn Baayen
Modified: 2010-08-18 16:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (3.52 KB, patch)
2007-04-06 13:51 UTC, Jorn Baayen
needs-work Details | Review
New patch (3.81 KB, patch)
2007-04-07 09:09 UTC, Jorn Baayen
needs-work Details | Review
Simple benchmark (951 bytes, text/x-csrc)
2007-04-11 15:16 UTC, Jorn Baayen
  Details
remove draw-border support (4.78 KB, patch)
2010-08-11 14:31 UTC, Matthias Clasen
none Details | Review

Description Jorn Baayen 2007-04-06 13:50:37 UTC
Calling gtk_widget_get_draw_rectangle() on containers that have a large number of children can be very slow.

This is becase gtk_widget_get_draw_rectangle() recursively calls widget_add_child_draw_rectangle() on all its children. This is necessary for handling the 'draw-border' style property.

When not using the 'draw-border' style property this is causing needless slowdown.

Attached patch adds draw rectangle caching.
Comment 1 Jorn Baayen 2007-04-06 13:51:08 UTC
Created attachment 85902 [details] [review]
Patch
Comment 2 Chris Wilson 2007-04-07 06:26:49 UTC
The cached_rect needs to be released on style change... But otherwise it looks like a clean method of killing one of the most frequent style queries (and allocator!).
Comment 3 Jorn Baayen 2007-04-07 09:09:18 UTC
Created attachment 85942 [details] [review]
New patch

Clear draw rectangle on style change.
Comment 4 Matthias Clasen 2007-04-11 14:22:49 UTC
There is another bug where I proposed a caching mechanism for the draw rectangles.
Maybe you can find it, and compare my patch ?
Comment 5 Matthias Clasen 2007-04-11 14:23:32 UTC
And also, a benchmark that shows performance benefits would be appreciated.
Comment 6 Jorn Baayen 2007-04-11 15:16:41 UTC
Created attachment 86170 [details]
Simple benchmark
Comment 7 Jorn Baayen 2007-04-11 15:17:28 UTC
(In reply to comment #4)
> There is another bug where I proposed a caching mechanism for the draw
> rectangles.
> Maybe you can find it, and compare my patch ?

I looked for it, but couldn't find anything ..

Comment 8 Matthias Clasen 2007-04-11 17:35:18 UTC
bug 157805
Comment 9 Jorn Baayen 2007-04-12 13:58:06 UTC
Thanks. Your patch focuses on style properties, while mine prevents a container's complete widget tree from being walked on every draw, reducing the number of draw-border queries as an (intended) side effect.
Comment 10 Matthias Clasen 2007-04-28 23:48:22 UTC
What I dislike about this caching is that it adds an extra rectangle to every single no-window widget, even if there are no draw borders around at all.
Can we arrange things to avoid that, e.g. by having a no-draw-border flag ?

Another thing: at the places where you clear the cache (due to resizing or style change), don't you have to clear the caches up the hierarchy ?
Comment 11 Tobias Mueller 2010-04-10 14:10:24 UTC
Jorn, could you address the issues raised in comment #10?

Is this bug still valid anyway?
Comment 12 Tobias Mueller 2010-05-26 15:05:15 UTC
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for.
Thanks!
Comment 13 Matthias Clasen 2010-05-26 15:32:54 UTC
I'd like to keep this open, to consider dropping the draw-rectangle functionality in gtk3.
Comment 14 Matthias Clasen 2010-08-11 14:31:47 UTC
Created attachment 167602 [details] [review]
remove draw-border support