-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
SQLAlchemy 2.0.0 takes forever to lint #8150
SQLAlchemy 2.0.0 takes forever to lint #8150
Comments
Can easily reproduce on macOS Python 3.11.0. For some variety, I also ran it with Running with Next step, use a profiler. |
Check Cumulative time
Pylint is spending 3x more cumulative time analyzing slqalchemy 2.xx than 1.4.xx Check Total Time
**The functions that are adding a significant amount more in sqlalchemy 2.xx are **:
|
Is there a temporary workaround for this? Is there a way to tell astroid / pylint to ignore this module entirely? Or is the best bet to uninstall sqlalchemy during builds, run pylint, re-install, and ignore import errors? If it helps, I modified the NodeNG to count how often it's called. W/O sqlalchemy, my linting finished with:
out of which following ClassDef counters:
WITH sqlalchemy, after around 1-2 minutes of work: The big overhead seems to come from Name and ClassDef.
out of which following ClassDef counters:
|
The best we have right now is:
I'm not sure that it's going to help in this case because you might need to infer a single value but the recursion involved to do that is catastrophically costly. Might be worth a try though. (Sorry for the semi-related joke but I'd like to introduce a new concept that I would call "design by ChatGPT": You know that your lib is not perfect and you want to make it better with intuitive configuration, so you ask chatGPT: What's the way to prevent catastrophic inference recursion in astroid using configuration ? Then ChatGPT tell you that: from astroid import conf
conf.MAX_INFERENCE_STEPS = 1000
conf.TYPING_HEURISTICS = False
conf.INFERENCE_TIMEOUT = 10
And bam, here's your design. Joke aside we talked about imposing a limit on inference by timeout or recursion limit, but it's not done right now, because then some messages would silently fail and be impossible to reproduce because the inference timed out or was cut unexpectedly.) |
Opened #8248 to discuss a long term solution. |
As a short-term workaround, I was able to pin sqlalchemy<2.0.0 via a constraints file and making sure to set the future=True argument (see also https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#migration-to-2-0-step-four-use-the-future-flag-on-engine ) |
I am seeing the Astroid module brain_namedtuple_enum.py has a big affect on the results: Standard Pylint run: time pylint example.py
pylint example.py 20.82s user 0.68s system 95% cpu 22.510 total With brain_namedtuple_enum.py removed from a local install of astroid: time pylint example.py
pylint example.py 8.83s user 0.48s system 93% cpu 9.977 total SQLAlchemy==2.0.0
Darwin Kernel Version 20.6.0 |
Sure happy to hear that root cause was fixed, but until fix is released I don't think it's correct to close this issue. I can install latest astroid and pylint (astroid==2.15.5, pylint==2.17.4), and sqlalchemy 2.x linting is still slow. |
We close issues when merging fixes, not when cutting releases. |
You can choose to install bleeding-edge astroid or wait for an alpha or a stable version, it's up to each user. |
The expected release milestone is marked in this issue. |
@jacobtylerwalls, I have been waiting for releases for a while, seems to be the latest
but linting time is still extremely huge
Do I miss anything? Which version of astroid/pylint is expected to contain the fix? |
Ah, looks like Is it expected in >3 and not sooner? |
Looks like
|
Yep, support for the latest astroid improvements only exists on the main branch until we can get a release out. You can install from the main branch with |
You'll notice there's only one issue left on the 3.0.0a7 milestone, which another maintainer regards as a release blocker. |
Bug description
Linting against
sqlalchemy
2.0.0 is infinitely slower that against 1.4 series.This was reported here: sqlalchemy/sqlalchemy#9181
Configuration
No response
Command used
time pylint slow.py
Pylint output
With sqlalchemy 2.0.0 time pylint slow.py ------------------------------------------------------------------- Your code has been rated at 10.00/10 (previous run: 7.50/10, +2.50) real 0m11.233s user 0m11.080s sys 0m0.112s
with 1.4.46
On real life use cases, it goes from 6 seconds to 90 !
OS / Environment
Fedora 34, conda environment
Additional dependencies
sqlalchemy
The text was updated successfully, but these errors were encountered: