mathics / Mathics

This repository is for archival. Please see https://github.com/Mathics3/mathics-core
https://mathics.org
Other
2.07k stars 205 forks source link

Reduce start-up time? #940

Open rocky opened 4 years ago

rocky commented 4 years ago

Running even a batch mathics can take a few seconds:

$ time mathics -e "1+2"
In[1]:= 1+2
Out[1]= 3

real    0m4.606s
user    0m4.822s
sys 0m2.231s

As was pointed out in #633 a bit of this is importing built-in modules. For the above, I have 1.2 seconds for the imports. Here is the breakdown:

import took 1.2 s:
    manipulate 0.329808
    plot 0.316342
    quantities 0.278026
    arithmetic 0.144492
    xmlformat 0.067233
    graphics3d 0.017286
    datentime 0.007003
    graphics 0.006026
    importexport 0.003843
    structure 0.003755
    ...

In the far future we might consider profiling the code or adding nice mechanism for gathering statistics as #633 did.

weakit commented 4 years ago

I think using lazy import would help to give a significant reduction in load time.

slel commented 4 years ago

+1.

Note that Sage uses lazy imports to significantly reduce startup time.

Sage patchbots check startup time to warn if any ticket worsens it.

rocky commented 4 years ago

Guessing and anecdotal evidence is one thing. Having hard evidence is another.

This is an open-source project which means that any one has the freedom and opportunity to partiicipate. My suggestion then is to take the code base and make your own experiments and experimental improvements. And if this looks promising then put in a PR.

Thanks in advance.

weakit commented 4 years ago

Will do.