extends python path, slowing down python imports

Bug #903180 reported by Jelmer Vernooij
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu One Client
Triaged
Undecided
Unassigned
ubuntu-sso-client (Ubuntu)
Triaged
Undecided
Unassigned
ubuntuone-control-panel (Ubuntu)
Triaged
Undecided
Unassigned
ubuntuone-couch (Ubuntu)
Won't Fix
Undecided
Unassigned
ubuntuone-installer (Ubuntu)
Triaged
Undecided
Unassigned
ubuntuone-storage-protocol (Ubuntu)
Triaged
Undecided
Unassigned

Bug Description

The various Ubuntu One Python modules each install .pth files, extending the default Python import path. This means that all applications that import Python modules will try to use these paths.

For example, for bzr, this means that every time bzr is run there are between 80 and 200 open/stat calls that are unnecessary. This isn't a huge cost, but it adds up to the overall startup time.

Is there a particular reason the ubuntu one modules are installed in a separate directory rather than in dist-packages, like other modules on an Ubuntu system?

Revision history for this message
dobey (dobey) wrote :

For the ubuntuone namespace projects at least, we need to do this, so that Python can import all our code properly, without having dependency hell as a result; and so that we can actually test code in a source checkout on a system that has the packages installed to the system.

For ubuntu-sso-client, this isn't actually necessary, so we can probably remove it from there.

Do you have any real numbers to compare with?

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 903180] Re: extends python path, slowing down python imports

On 12/12/2011 05:29 PM, Rodney Dawes wrote:
> For the ubuntuone namespace projects at least, we need to do this, so
> that Python can import all our code properly, without having dependency
> hell as a result; and so that we can actually test code in a source
> checkout on a system that has the packages installed to the system.
Is it really necessary to have so many though, wouldn't one be sufficient?

>
>
> For ubuntu-sso-client, this isn't actually necessary, so we can probably
> remove it from there.
>
> Do you have any real numbers to compare with?
It seems to add some overhead for each failed import. Failed imports
aren't impossible - some things use import to see if their dependencies
are present. On my system it adds something like 0.013s (looking at
strace) to the bzr startup time from the ubuntuone pth files alone.
That's not a huge impact - the total startup time for bzr here is 0.25s.
It does contribute to the overal overhead though - and it doesn't just
impact bzr, but anything in Python that has one or more failing imports.
Ubuntuone isn't the only application that adds a pth file, but it is the
only that adds so many.

I don't think this urgently needs fixing or anything like that, but it
did seem significant enough to file a bug about.

Cheers,

Jelmer

Rick McBride (rmcbride)
Changed in ubuntuone-client:
status: New → Triaged
Changed in ubuntuone-control-panel (Ubuntu):
status: New → Triaged
Changed in ubuntuone-couch (Ubuntu):
status: New → Triaged
Changed in ubuntuone-installer (Ubuntu):
status: New → Triaged
Changed in ubuntuone-storage-protocol (Ubuntu):
status: New → Triaged
Changed in ubuntu-sso-client (Ubuntu):
status: New → Triaged
dobey (dobey)
Changed in ubuntuone-couch (Ubuntu):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.