-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff contains a major rewrite of the cross-module ("merge") phase of Flow's type-checking algorithm, enabling huge performance wins for both init and recheck times (order of magnitude for large-enough code bases). The main difference is that whereas earlier, all N files would be merged with their recursive dependencies independently in parallel, now the merging is orchestrated, so that files are merged only after all their dependencies are merged. (Cycles are, of course, merged together.) Overall, this means that shared dependencies are not merged over and over again, but instead only once. (Results of merging are stored and reused.) For long chains of sharing, this leads to a big-O reduction in work (from quadratic to linear). Furthermore, the memory footprint for results of merging is quite small, since they only need to describe signatures. This leads to very low overhead for the additional (de)serialization between shared memory. Since the work queue for workers dynamically grows and shrinks in this scheme, simple bucketing (by cutting off chunks from a static queue) doesn't work. This diff adds support for a more general bucketing protocol that signals workers to wait in addition to providing work, and implements such a bucketing protocol for the new merging strategy. For compressing the results of merging, this diff also implements a context optimizer that walks a context from its exported signature and records only the parts of the context that need to be preserved. These improvements vastly bring down init times (as well as recheck times). In addition, some previously slow dependency calculations have now been parallelized, which lead to further vast gains in recheck times (as well as init times). Entry points to various client commands have been accordingly updated. A final improvement worth mentioning that is not directly related to perf but was necessary for ensuring correctness is that builtins references are now treated like other module references: every context has its own reference and they are linked during merging (whereas earlier there used to be a single global reference shared by all contexts). Reviewed By: @bhosmer Differential Revision: D2320934
- Loading branch information
1 parent
8f0aed3
commit 17196e8
Showing
42 changed files
with
1,153 additions
and
638 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.