Repository navigation
Split large SCCs in parallel mode - #22541
Open
ilevkivskyi wants to merge 4 commits into
Open
ilevkivskyi wants to merge 4 commits into
ilevkivskyi wants to merge 4 commits into
Conversation
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.
This makes libraries like
torch~2x faster (tested with-n8), and self-check is up to 10% faster (again for-n8, with fewer workers gains are smaller).Basic idea and technical side are quite straightforward. However, details of the sharding and scheduling logic are quite tricky. This is partially because I made a mistake when measuring interface vs implementation time: right now ~30-40% of time is spent in loading+interface. Most of it is spent in semantic analysis. This makes splitting semantic analysis into two phases imperative, if we want to see full gains from this PR.
Here are some important details of the PR.
First, we need to be sure that splitting will be effective, this means all of these must be true:
Second, we should split eagerly. It is quite common that a large bottleneck SCC arrives in the queue while there is only one free worker. The other will become free soon, so if we don't split, they all will be idling.
Third (the consequence of above), we should minimize interface penalty in case where we have split an SCC, but it was actually not needed. For example, if some other worker soon unblocked a big chunk of parallelizable work. For this purpose I introduce affinity for workers processing sharded SCCs. When a worker becomes free:
Note I also did some refactoring in worker code, since
serve()function grew too large. I didn't do much parameter tuning. I think we should merge this PR, then try splitting the semantic analysis, and then I will do some parameter tuning.cc @JukkaL