mdbartos/pysheds

Numba JIT causes up to 15s import times

fluffbucket opened this issue · 4 comments

Compiling sGrid and whatever else uses Numba takes up to 15seconds every time causing long bootup times, consider using AOT instead with Numba.

Measured with cProfile around importing pysheds grid and raster

Hi @fluffbucket, all of the functions use numba's caching option to store the compiled code:

cache=True)

It should just compile once the first time you use it and then not compile again unless modified.

Hi @fluffbucket I'm wondering if you're using Windows? I'm having issues using from pysheds.grid import Grid and it seems to crash in _sgrid.py around def _d8_catchment_iter_numba. I'm thinking it's a Windows thing maybe?

I've noticed numba sometimes has problems on Windows with the functions that use numba implementations of linked lists and dictionaries. You may want to try using algorithm='recursive' in your call to grid.catchment and see if it's more stable.

I haven't been able to reproduce the 15+ second loading times though. I suspect that you may have a caching issue that is causing everything to be re-compiled each time you import.