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

with --files, coala executes every file in separate process, so that mypy checks run very slowly #6130

Open
remort opened this issue Dec 10, 2020 · 2 comments

Comments

@remort
Copy link

remort commented Dec 10, 2020

Steps to reproduce:
Run Coala, with mypy bear enabled only, over catalog with code running this command:
coala --ci -c .coarc --files $(find . -iname '*.py')
It will run several minutes (~4m) on my 66 files found.
If you run mypy itself, passing it the same file list (mypy $(find . -iname '*.py')) - it will finish all the checks in several (~12) seconds (see example below).

Looking at top (top -b to see full command line for every process) I realized that coala run mypy over every file.
So 66 files leads to consequent 66 runs of mypy passing it a particular filename each time.

You can emulate exactly this slow behaviour by running following code:
for line in $(find . -iname '*.py'); do /usr/local/bin/python -m mypy --python-version 3.6 "$line"; done
The for-loop will be finished in several minutes. Being run file-by-file, mypy works very slow.

The exact command with python -m mypy... taken from top batch output. That's how Coala run mypy,pylint, etcetera python linters.

The following code runs mypy over all the same 66 files in ~12 seconds:

# date +%M:%S;/usr/local/bin/python -m mypy --python-version 3.6 $(find . -iname '*.py'); date +%M:%S
55:49
Success: no issues found in 66 source files
56:01

That's how we should run linter executable over bunch of files.
Simultaneous multiprocessing jobs counted by '--jobs' option, as you run linters inside coala, shouldn't be an issue.
You can divide files bu number of jobs and pass every chunkof files to it's job, for example.
Job should run linter executable just once, passing an entire chunk of files to the linter's command line.

@remort
Copy link
Author

remort commented Dec 10, 2020

date +%M:%S;for line in $(find . -iname '*.py'); do /usr/local/bin/python -m mypy --python-version 3.6 "$line"; done;date +%M:%
59:00   
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
Success: no issues found in 1 source file
05:52

That is how slow mypy works if you feed it with files one-by-one like Coala does.

@remort remort changed the title with --files, coala executes every file in separate process. so f.e. mypy checks run very slowly with --files, coala executes every file in separate process, so that mypy checks run very slowly Dec 10, 2020
@PrasanthChettri
Copy link

Hi can I be assigned this issue ?

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

No branches or pull requests

2 participants