Parse files in parallel when possible#21175
Open
ilevkivskyi wants to merge 3 commits intopython:masterfrom
Open
Parse files in parallel when possible#21175ilevkivskyi wants to merge 3 commits intopython:masterfrom
ilevkivskyi wants to merge 3 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The idea is simple: new parser doesn't need the GIL, so we can parse files in parallel. Not sure why, but the most I see is ~4-5x speed-up with 8 threads, if I add more threads, it doesn't get visibly faster (I have 16 physical cores).
Some notes on implementation:
ThreadPoolExecutor, it seems to work OK.parse_file()a bit, so that we can parallelize (mostly) just the actual parsing. I see measurable degradation if I try to parallelize all ofparse_file().psutilbecause it is an optional dependency. We may want to actually make it a required dependency at some point.ast_serializeto beNonesometimes in some threads. I simply add an ugly workaround for now.cc @JukkaL