[Sugar-devel] [Dextrose] [PATCH v5 sugar] Pulsing icon delayed by 5 seconds or so SL#2080

Martin Dengler martin at martindengler.com
Fri Oct 29 04:47:33 EDT 2010


On Fri, Oct 29, 2010 at 10:56:25AM +1100, James Cameron wrote:
> On Thu, Oct 28, 2010 at 03:44:37PM -0300, Gonzalo Odiard wrote:
> > I think the problem is the code is rendering the svg icon every time
> > the color is changed.  There are not cache or cairo operation used to
> > avoid this.
> 
> I agree.  Martin Dengler's stats graph confirms it.
> 
> Anurag is proposing skipping the paint after the first rendering.  It
> remains a puzzle to me why the first frame rendering takes so much
> longer than the remaining frames.
> 
> In Netrek when I faced this kind of problem, I solved it by
> pre-rendering a reduced number of frames, or at least caching the
> rendered frames.
> 
> The frame rate is 10 Hz.  The _phase is continually incremented, and the
> level is set using:
> 
> 	self._level = (math.sin(self._phase) + 1) / 2
> 
> The first two seconds uses these levels:
> 
> 0.500000
> 0.920735
> 0.954649
> 0.570560
> 0.121599
> 0.020538
> 0.360292
> 0.828493
> 0.994679
> 0.706059
> 0.227989
> 0.000005
> 0.231714
> 0.710084
> 0.995304
> 0.825144
> 0.356048
> 0.019301
> 0.124506
> 0.574939
> 
> Now if these were filtered to a reduced set of levels, the rendered
> images could be cached and re-used.
> 
> 	N = 10
> 	self._level = int(math.sin(self._phase) + 1) / 2 * N) / N

I'm interested in what you mean here.  I applied this patch:

$ diff -u ./source/sugar/src/jarabe/view/pulsingicon.py ./install/lib/python2.6/site-packages/jarabe/view/pulsingicon.py 
--- ./source/sugar/src/jarabe/view/pulsingicon.py       2010-09-14 11:02:24.566582134 +0800
+++ ./install/lib/python2.6/site-packages/jarabe/view/pulsingicon.py 2010-10-29 16:42:40.156372299 +0800
@@ -78,7 +78,8 @@
 
     def __pulse_cb(self):
         self._phase += _STEP
-        self._level = (math.sin(self._phase) + 1) / 2
+        N = 10.0
+        self._level = round((math.sin(self._phase) + 1) / 2, 3)
         self.update()
 
         return True

...and I didn't see much change with my test program[1]:

$ for i in $(seq 1 10) ; do ./profile-pulsingicon.py >> ./profiling_results-before.txt 2>&1; done \
  patch ./install/lib/python2.6/site-packages/jarabe/view/pulsingicon.py  ~/tmp/pulsingicon.py-filter-_level_to_ten.patch \
  for i in $(seq 1 10) ; do ./profile-pulsingicon.py >> ./profiling_results-after-filtering.txt 2>&1; done 

$ grep render_cairo profiling_results-before.txt | sed -e 's/{.*render_cairo.*}/render_cairo/'
[  ncalls  tottime  percall  cumtime  percall   function  ]
       60    0.438    0.007    0.438    0.007 render_cairo
       70    0.501    0.007    0.501    0.007 render_cairo
       68    0.498    0.007    0.498    0.007 render_cairo
       69    0.511    0.007    0.511    0.007 render_cairo
       67    0.496    0.007    0.496    0.007 render_cairo
       66    0.473    0.007    0.473    0.007 render_cairo
       68    0.491    0.007    0.491    0.007 render_cairo
       72    0.530    0.007    0.530    0.007 render_cairo
       69    0.496    0.007    0.496    0.007 render_cairo
       67    0.488    0.007    0.488    0.007 render_cairo

$ grep render_cairo profiling_results-after-filtering.txt | sed -e 's/{.*render_cairo.*}/render_cairo/'
[  ncalls  tottime  percall  cumtime  percall   function  ]
       64    0.491    0.008    0.491    0.008 render_cairo
       64    0.475    0.007    0.475    0.007 render_cairo
       64    0.458    0.007    0.458    0.007 render_cairo
       64    0.463    0.007    0.463    0.007 render_cairo
       64    0.438    0.007    0.438    0.007 render_cairo
       64    0.459    0.007    0.459    0.007 render_cairo
       64    0.455    0.007    0.455    0.007 render_cairo
       64    0.467    0.007    0.467    0.007 render_cairo
       64    0.479    0.007    0.479    0.007 render_cairo
       64    0.473    0.007    0.473    0.007 render_cairo


Can you suggest some corrections to what I've done?

Martin

1. http://www.martindenglerm.com/tmp/sl.o-2080/profile-pulsingicon.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101029/ca144f9b/attachment-0001.pgp>


More information about the Sugar-devel mailing list