Optimizing spray&memory swapping

LukasT.dev@gmail.com lukast.dev at gmail.com
Thu Apr 22 18:27:11 CEST 2010


Hello,

I did some profiling of the spray and I run into some strange issues.
Basically it is about fillPainterPath method in KisPainter.

In spray it is used heavily when painting circles, ellipses, rectangles.
It might be a nice idea to try to use mask generators instead because now they 
support also rotation and when I wrote spray, rotation was not there so I used 
my own code to write polygons and fill them with fillPainterPath.

From the profiling data [1] I noticed that there is KisPaintDevice 
created&destroyed per sprayed particle and that is slow. I produced patch [2] 
that reuse KisPaintDevice with clear() but then I run the benchmarkRandomLines 
and all my ram memory was filled with data, the computer stopped to respond for 
two minutes because of swapping. 

I used this setting of the spray [3] and [4]. One use two particles, the other 
one 21 particles.

I could reproduce the swapping and memory madness also inside Krita (The 
memory swapping was discovered by running KisStrokeBenchmark with those 
settings and using benchmarkRandomLines). To reproduce I just select the 
preset [3] and do infinite stroke with mouse in circle. I was stopped by 
swapping. This swapping is present only with the patch [2], when in Krita, 
I feel just some slowdown in time doing the stroke.

I don't know what is going on. Have you got any idea? Is there some leak? 

[1] http://lukast.mediablog.sk/callgrind/spraybrush-profiling.tar.gz
[2] http://lukast.mediablog.sk/patches/reuse-kisPaintDevice.patch
[3] http://lukast.mediablog.sk/presets/spray_scaled2rasterParticles.kpp
[4] http://lukast.mediablog.sk/presets/spray_30px21rasterParticles.kpp


More information about the kimageshop mailing list