Today I've been doing a lot of test to my XO-B4 machine, I was looking for different ways in order to speedup the Sugar Shell, and I found an interesting project called Psyco:
"In short: run your existing Python software much faster, with no change in your source. Think of Psyco as a kind of just-in-time (JIT) compiler, a little bit like what exists for other languages, that emit machine code on the fly instead of interpreting your Python program step by step. The difference with the traditional approach to JIT compilers is that Psyco writes several version of the same blocks (a block is a bit of a function), which are optimized by being specialized to some kinds of variables (a "kind" can mean a type, but it is more general). The result is that your unmodified Python programs run faster."
Testing Joyride 227, I decided to install Psyco and do some benchmark with it to the Sugar Shell using the profile() method provided. Psyco gives to every method/function/call an "importance level" so I got a lot of interesting data about which calls are more heavier than others, by default the profile system shows the top ten heavy calls:
01:08:31 AM.77 ______
#1 | 5.7 %| do_paint_below_children .../graphics/icon.py:448
#2 | 5.3 %| ...r/bin/sugar-shell:18
#3 | 5.2 %| _get_cache_key .../graphics/icon.py:93
#4 | 5.0 %| get_surface .../graphics/icon.py:201
#5 | 5.0 %| _get_xo_color .../graphics/icon.py:187
#6 | 4.7 %| _parse_string ...aphics/xocolor.py:203
#7 | 3.8 %| do_set_property .../graphics/icon.py:392
#8 | 3.5 %| _pulse_cb ...ctivitiesdonut.py:148
#9 | 3.4 %| __init__ ...aphics/xocolor.py:219
#10 | 2.8 %| buildfncache ...psyco/profiler.py:66
01:08:33 AM.66 ______
#1 | 7.5 %| do_paint_below_children .../graphics/icon.py:448
#2 | 6.1 %| _get_xo_color .../graphics/icon.py:187
#3 | 5.2 %| __init__ ...aphics/xocolor.py:219
#4 | 5.0 %| ...r/bin/sugar-shell:18
#5 | 5.0 %| get_surface .../graphics/icon.py:201
#6 | 4.4 %| _get_cache_key .../graphics/icon.py:93
#7 | 4.2 %| _pulse_cb ...ctivitiesdonut.py:148
#8 | 4.1 %| _parse_string ...aphics/xocolor.py:203
#9 | 2.8 %| do_set_property .../graphics/icon.py:392
Psyco doesn't try to improve the performance of all your software, you have to tell it which calls you want to improve, obviously you want to decrease the importance level of the ones that are heavier. For this, Psyco provides a pysco.bind() method where you decide which one to improve. I got good results, the importance level of the calls chosen has decreased and I can see that Sugar is a little bit faster than before but... it takes a little more time to start and it takes more memory than usual. I'll continue doing more tests to get real values of this optimization.