sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 475 forks source link

Improve startup time for Python3-based Sage #26482

Open slel opened 6 years ago

slel commented 6 years ago

Python3-based Sage seems to start up much slower than Python2-based Sage.

CC: @fchapoton @embray @saraedum @slel @williamstein

Component: python3

Issue created by migration from https://trac.sagemath.org/ticket/26482

embray commented 6 years ago
comment:1

Indeed. This has been a problem for as long as I've been working on the Python 3 port, and it's not clear to me why. I suspect it has mostly to do with the import system. On the one hand, the new import system has some caching to reduce the number of syscalls needed for many import calls. OTOH that cache has to be filled in the first place, and that might still be slower in the extreme case of Sage. I need to investigate this but haven't even started to yet.

fchapoton commented 5 years ago
comment:2

see #8254

fchapoton commented 5 years ago
comment:3

see rather #26908

embray commented 5 years ago
comment:4

Since #26908 this is vastly improved. Startup time is still a bit slower than on Python 2, but it's much more marginal, and it might be harder to track down any specific deficiencies in this area. Though I certainly wouldn't discourage anyone from trying.

I still believe there are big gains to be made in general with lazy imports. I don't think we need to really import everything that makes up the Sage global namespace if we can replace most of it with proxies.