Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First launch of new glue version is slow (before loading splash screen) #2424

Open
jfoster17 opened this issue Jul 14, 2023 · 1 comment
Open

Comments

@jfoster17
Copy link
Member

Is your feature request related to a problem? Please describe it:
The first time you launch a new version of glue (e.g. a new standalone app or glue within a new virtual environment) it is quite slow. On my Mac, the application icon appears in the dock, but that is the only thing that happens for ~15-20 seconds. After that, the splash/loading screen appears for a second, and then the application is open. Subsequent launches are very quick, but this initial introduction to glue to be off-putting to new users who may think glue is (a) not working or (b) will always be slow.

Describe the solution you'd like:
We should understand why glue is slow to launch the first time, and see if we can ameliorate the problem. If it is something we cannot reduce, we should see if it is at least possible to put up the splash screen before whatever the slow step is.

@astrofrog
Copy link
Member

To investigate this, I made a new Python environment and installed glue along with glue-wwt and glue-vispy-viewers:

python -m venv ~/python/clean2
source ~/python/clean1/bin/activate
pip install glue-core PyQt6 glue-vispy-viewers glue-wwt PyQt6-WebEngine

Then I made a small script:

from glue.main import main
main()

and called it start_glue.py, then ran:

python -X importtime start_glue.py 2> import.log

and installed tuna and ran:

tuna import.log

which makes a nice visualization of import times:

Screenshot 2023-07-14 at 21 02 49

You can also see import.log here: https://gist.github.com/astrofrog/c12262e3096cceb433d3012c814e1210
Note that this is only for the first import (which is relevant for this issue) - subsequent imports are a lot faster, so if you want to profile again you have to make a new venv.

The first import takes >12s in this case! PyQtWebEngine is a clear culprit, but I think there are in general a LOT of dependencies that get imported at start time and contribute to this.

I wonder if we should go though and figure out if we can delay some of the imports at least until the splash screen is showing, or even until the functionality is actually used. For instance, there's no reason we should be importing scipy or casa-formats-io or pandas when the application is starting up. We should be delaying many of the imports

I think there will be other things that cause the first start of the application to be slow when downloading a new DMG, but if we can at least make the import part faster then that might make a big enough difference to make the delay bearable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants