Plasma::Svg and performance

Marco Martin notmart at gmail.com
Wed Oct 15 11:06:28 CEST 2008


On Wednesday 15 October 2008, Aaron J. Seigo wrote:
> 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:

will try the patch, i'm willing to do something aout it...
i was thinking about a QHash of rects keps by Svg, so haselement is a check 
for the existence of the key elementRect fetches the value and elementsize its 
size
the first time calles well, still suck, but inevitable...
all the cache kiled on theme changed annd when the svg changes on disk how 
behave? hmmm...

Cheers,
Marco Martin

> 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?




More information about the Plasma-devel mailing list