E0401 (import-error) checks perform repeated file reads #9603
Labels
Astroid
Related to astroid
Enhancement ✨
Improvement to a component
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
performance
Bug description
This is a follow-up to #9310, where I reported slowness with
import-error
checks due to repetitive I/O over SSHFS.While profiling the new code, I noticed that the
_is_setuptools_namespace
checks in astroid cause the same files to be read over and over.My public example repo shows the following reads:
pylint-corpus/src/__init__.py
pylint-corpus/src/resources/sites/pages/page.py/__init__.py
pylint-corpus/src/resources/results/result.py/__init__.py
I'm hoping that the repeated reads can be prevented to speed up pylint. (My private repo has ~2,200 files and shows >20,000 repeated reads.)
Configuration
Command used
Steps to reproduce
git clone --branch import-error-stats https://github.com/correctmost/pylint-corpus.git cd pylint-corpus python ./profile_pylint.py
Analysis
strace shows the same files being opened repeatedly:
It seems possible to avoid most of these reads with caching around
_is_setuptools_namespace
, but I wonder if_is_setuptools_namespace
should even be called with a non-directory path (notice theENOTDIR
errors)?Python profiling:
Pylint output
There is no output, just reduced performance
Expected behavior
Improved performance via caching or reduced filesystem accesses
Pylint version
OS / Environment
Arch Linux
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: