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

perf: cache entry points #10889

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Conversation

NickCrews
Copy link
Contributor

@NickCrews NickCrews commented Feb 24, 2025

This is a sibling to #10888

Without this change, running
pytest --collect-only --doctest-modules --full-trace on https://github.com/NickCrews/mismo takes 2.76s. With this change, it takes 1.21s

This is because every time pytest visits a module during test collection, it has to determine if each object inside the module is a test. During that process, it calls https://github.com/pytest-dev/pytest/blob/77f2c63a542fc9511f5919ddf7f4b64d237fda07/src/_pytest/python.py#L343, on every item. If I have a module where I do import ibis, then this means that we attempt to do ibis.__test__, which triggers the __getattr__ function in ibis/__init__.py, which then goes out and loads the entry points. Turns out this is a slow process for packages with many such modules (mismo has ~100 such modules).

NickCrews and others added 2 commits February 24, 2025 05:30
Without this change, running
`pytest --collect-only --doctest-modules --full-trace`
on https://github.com/NickCrews/mismo takes 2.76s. With this change, it takes 1.21s

This is because every time pytest visits a module during test collection,
it has to determine if each object inside the module is a test. During that process, it calls https://github.com/pytest-dev/pytest/blob/77f2c63a542fc9511f5919ddf7f4b64d237fda07/src/_pytest/python.py#L343, on every item. If I have a module where I do `import ibis`, then this means that we attempt to do `ibis.__test__`, which triggers the `__getattr__` function in `ibis/__init__.py`, which then goes out and loads the entry points. Turns out this is a slow process.
@cpcloud cpcloud force-pushed the perf-cache-entrypoints branch from 23264f1 to 5d59a1d Compare February 24, 2025 10:37
@cpcloud cpcloud enabled auto-merge (squash) February 24, 2025 10:38
@github-actions github-actions bot added the tests Issues or PRs related to tests label Feb 24, 2025
@cpcloud cpcloud merged commit 62e9bca into ibis-project:main Feb 24, 2025
88 of 89 checks passed
cpcloud added a commit to cpcloud/ibis that referenced this pull request Feb 25, 2025
cpcloud added a commit to cpcloud/ibis that referenced this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants