Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce import time #438

Open
nspope opened this issue Nov 11, 2024 · 9 comments
Open

Reduce import time #438

nspope opened this issue Nov 11, 2024 · 9 comments

Comments

@nspope
Copy link
Contributor

nspope commented Nov 11, 2024

The import time (due to numba AOT compilation) is driving me nuts-- I wonder if there's a way we can build an extension optionally on install (e.g. triggered by a flag to pip). Jerome and others have had bad experiences with numba extensions, but 30 to 60 seconds for import really slows down the debug cycle, and if extension-building is turned off by default I don't think it'd be an issue.

@hyanwong
Copy link
Member

I agree it's a pain. I'll check with @jeromekelleher and @benjeffery if there is a sensible solution in this case.

@jeromekelleher
Copy link
Member

One simple thing is to turn caching on/off using an environment variable. So you turn on caching for dev, and it's off by default: https://github.com/sgkit-dev/sgkit/blob/main/sgkit/accelerate.py

Would this help?

@hyanwong
Copy link
Member

That sounds like a great suggestion. Thanks @jeromekelleher

@nspope
Copy link
Contributor Author

nspope commented Nov 13, 2024

That's a good suggestion @jeromekelleher and should be fine for development, thanks. I'm also pondering moving some of the core routines into a rust extension, in the long term.

@jeromekelleher
Copy link
Member

I'm also pondering moving some of the core routines into a rust extension, in the long term.

eek!

@nspope
Copy link
Contributor Author

nspope commented Nov 13, 2024

It's not that bad, I hope! What I'm trying to say is I'd like to move some of the low-level EP stuff into a compiled language extension, to save on import time, as this is just going to keep creeping up. Rust is great for numerical stuff and plugs in really nicely to Python.

(One of the motivations here is that we're using tsdate in simulation-based-inference contexts where we generate a bunch of simulations in parallel to train a neural network-- waiting >60 sec for import when running tsdate from the CLI is really a huge time sink in this application).

@hyanwong
Copy link
Member

Do you want to implement the environment variable caching, or do you want me to, @nspope ?

@jeromekelleher
Copy link
Member

Should definitely make caching an option for people who know what they're doing, 60s is horrendous.

If you paste in a profile I can comment on some possible ameliorations - that sounds much worse than it should be

@nspope
Copy link
Contributor Author

nspope commented Nov 13, 2024

Do you want to implement the environment variable caching

I'll play around with it a bit then ping you both. It's annoying but not super urgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants