[sugar] python activities startup
Tomeu Vizoso
tomeu at tomeuvizoso.net
Wed Feb 6 09:39:57 EST 2008
On Wed, 2008-02-06 at 09:31 -0500, 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.
AFAIK, what is taking most of the time here is the code at the module
level that is executed the first time that module is imported, and not
the reading and loading of modules. I think Michael Stone can confirm
this.
If I understand correctly how that fork() would work, what we would be
saving in that case is the reading of modules, but the python code at
the module scope would need to be executed anyway.
Tomeu
More information about the Sugar
mailing list