[Python-Dev] VM imaging based launch optimizations for CPython?

Mikko Ohtamaa mikko+python at redinnovation.com
Sat Dec 20 20:27:15 CET 2008


Hi fellow snakemen and lizard ladies,

We have been recently done lots of Python work on Nokia Series 60 phones and
even managed to roll out some commercial Python based applications. In the
future we plan to create some iPhone Python apps also.

Python runs fine in phones - after it has been launched. Currently the
biggest issue preventing the world dominance of Python based mobile
applications is the start up time. We cope with the issue by using fancy
splash screens and progress indicators, but it does't cure the fact that it
takes a minute to show the main user interface of the application. Most of
the time is spend in import executing opcodes and forming function and class
structures in memory - something which cannot be easily boosted.

Now, we have been thinking. Maemo has fork() based Python launcher (
http://blogs.gnome.org/johan/2007/01/18/introducing-python-launcher/) which
greatly speed ups the start up time by holding Python in memory all the
time. We cannot afford such luxury on Symbian and iPhone, since we do not
control the operating system. So how about this

1. A Python application is launched normally

2. After VM has initialized module importing and reached a static launch
state (meaning that the state is same on every launch) the VM state is
written on to disk

3. Application continues execution and starts doing dynamic stuff

4. On the following launches, special init code is used which directly blits
VM image from disk back to memory and we have reached the static state again
without going whoops of executing import related opcodes

5. Also, I have heard a suggestion that VM image could be defragmented and
analyzed offline

Any opinions?

Cheers,
Mikko


-- 
Mikko Ohtamaa
Red Innovation Ltd.
Oulu, Finland
http://www.redinnovation.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20081220/3696b62e/attachment-0001.htm>


More information about the Python-Dev mailing list