mind-inria / mri-nufft

Doing non-Cartesian MR Imaging has never been so easy.
https://mind-inria.github.io/mri-nufft/
BSD 3-Clause "New" or "Revised" License
48 stars 9 forks source link

Make imports faster? #7

Open chaithyagr opened 1 year ago

chaithyagr commented 1 year ago

For now imports seem really slow, make it faster for faster debug cycles

paquiteau commented 1 year ago

Are you still facing this issue ?

paquiteau commented 2 months ago

So I am facing this issue now (using multiprocessing) I have made some basic profiling using tuna for the visualization.

As we can see, the loading time is mostly due to external libraries (torch, sigpy, matplotlib and sigpy) are in the top three.

However, after this initial import there is no extra cost (import are cached internally by python)

Several possibilities:

Related stuff: https://stackoverflow.com/questions/4177735/best-practice-for-lazy-loading-python-modules https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Import_Statement_Overhead

Reproducing the profiling:

python -X importtime -c "import mrinufft"  2> import.log
tuna import.log

image