Plasma::Svg and performance

Aaron J. Seigo aseigo at kde.org
Wed Oct 15 06:40:13 CEST 2008


hi ..

doing some profiling with valgrind/massif, i noticed that a large amount of 
start up processing and memory usage is spent in parsing SVGs. surprise! ;)

i introduced a KPixmapCache for on-disk caching to help prevent the need to 
render from the source SVG over and over.

i was able to squeeze ~1MB of RAM usage out by doing that. but we can be even 
better ....

right now what is kicking us in the teeth is accessing embedded hints in the 
SVG file. turns out they are SUCH a great idea after all ;) at least not when 
we don't cache them, resulting in unecessary parsing of the SVG.

in particular, those include:

hint-apply-color-scheme - checked every time setImagePath is called

hint-*-margin - checked whenever PanelSvg::updateSizes is called

additionally, the following methods kill us:

Svg::hasElement (mostly called from PanelSvg::hasElementPrefix)
Svg::elementSize
Svg::elementRect

i decided to try tackling the first one, hint-apply-color-scheme, by caching 
that in the global config file.. turns out this help us avoid creating the 
renderer in a huge number of cases. in fact, with the attached patch applied, 
after the first run only PanelSvg cause us to hit createRenderer method.

just getting rid of the embedded hints isn't going to help us any: 
elementSize, elementRect and hasElement will still trigger unecessary 
createRenderer() calls.

so i'm thinking that it might make sense to keep a cache of some sort for all 
these parameters so that we only end up opening the SVG files to do new 
rendering.

one outstanding issue will be clearing the disk and parameter caches when the 
theme is updated on disk but not changed in the config.

before i go any further with this approach: any thoughts, ideas, inspirations?

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Software

-------------- next part --------------
A non-text attachment was scrubbed...
Name: svg_kpixmapcache.diff
Type: text/x-patch
Size: 11014 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20081014/2408dd91/attachment.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20081014/2408dd91/attachment.sig 


More information about the Plasma-devel mailing list