python activities startup

david at lang.hm david at lang.hm
Thu Feb 7 01:25:33 EST 2008


On Wed, 6 Feb 2008, Benjamin M. Schwartz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tomeu Vizoso wrote:
>> By the data in #5228, looks like more than 50% of time is spent
>> importing modules. dbus, telepathy and pygtk make for more than 30% of
>> _total_ startup time.
>
> There has been much talk about fork()ing the python interpreter for each
> activity instead of starting a new interpreter.  AFAIK, the python interpreter
> only does nontrivial work the first time a module is imported in each
> interpreter.  By this logic, if we use a forked interpreter and import these
> modules at the root, it seems that the import will only have to happen once at
> Sugar startup, rather than once for each Activity.
>
> I would appreciate a comment on this from someone who knows more about the
> relevant issues, like the interaction of CoW memory and python modules.

I can't comment on python modules, but I've seen similar issue on shared 
libraries with firewall proxies that did a fork for each connection. when 
they used a bunch of shared libraries, the cost of library setup at each 
fork was pretty significant (enough to cut the throughput by a factor of 
10 compared to a staticly linked version)

if you can get the linking and initialization step down to once per boot 
it will bee a huge win.

David Lang



More information about the Devel mailing list