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

Implement lazy loading in rerun/__init__.py #4054

Open
abey79 opened this issue Oct 28, 2023 · 0 comments · May be fixed by #4058
Open

Implement lazy loading in rerun/__init__.py #4054

abey79 opened this issue Oct 28, 2023 · 0 comments · May be fixed by #4058
Labels
🧑‍💻 dev experience developer experience (excluding CI)

Comments

@abey79
Copy link
Contributor

abey79 commented Oct 28, 2023

Situation

Currently, loading our SDK takes approximately ~350ms (2021 M1 Max), incurred primarily by loading numpy, PIL, and PyArrow.

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

This is particular impactful when running python -m rerun to launch a viewer (since #4053, using the rerun script is much faster), but probably also impacts (simple) logging script.

Currently, ~50% of the loading time is incurred by Numpy+PyArrow. This is probably unavoidable as no use-case realistically exists that doesn't require any of those, at least indirectly (it's pervasive in our implementation).

However, our using of a large number of files does incur a cost that is non negligible:

image

In the case of datatypes, about 5-6% are fixed cost (numpy stuff, base class, etc.), but the remaining 10-11% is the sum of all datatypes, lots of which might not be actually need by user code. The same story applies for archetypes (~4%) and components (~4%). Today, this is not much (<20%, ~60ms?), but with a grow in time as our API becomes more rich.

Possible solutions

Multiple project make use of __init__.py-level __getattr__() to implement lazy loading:

Something like this, combined with codegen, should be feasible without too much pain.

@abey79 abey79 added 🪳 bug Something isn't working 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 28, 2023
@abey79 abey79 linked a pull request Oct 29, 2023 that will close this issue
6 tasks
@abey79 abey79 added 🧑‍💻 dev experience developer experience (excluding CI) and removed 🪳 bug Something isn't working 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant