Mathics icon indicating copy to clipboard operation
Mathics copied to clipboard

Reduce start-up time?

Open rocky opened this issue 5 years ago • 4 comments

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.

rocky avatar Oct 03 '20 01:10 rocky

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

weakit avatar Oct 09 '20 06:10 weakit

+1.

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

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

slel avatar Oct 09 '20 08:10 slel

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.

rocky avatar Oct 09 '20 08:10 rocky

Will do.

weakit avatar Oct 09 '20 09:10 weakit