Skip to content

[Dependency Scanning] Implement parallel imported module resolution #68252

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

Merged
merged 2 commits into from
Sep 25, 2023

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Sep 1, 2023

  • [Dependency Scanning] Refactor primary scan operations into ModuleDependencyScanner class
    From being a scattered collection of static methods in ScanDependencies.cpp
    and member methods of ASTContext. This makes ScanDependencies.cpp much easier
    to read, and abstracts the actual scanning logic away to a place with common
    state which will make it easier to reason about in the future.

  • [Dependency Scanning] Implement parallel imported module resolution
    ModuleDependencyScanner maintains a Thread Pool along with a pool of workers
    which are capable of executing a filesystem lookup of a named module dependency.
    When resolving imports of a given Swift module, each import's resolution
    operation can be issued asynchronously.

For the time being, the scanner is restricted to still run single-threaded, with a new frontend option -parallel-scan enabling multi-threaded dependency scanning.

@artemcm artemcm force-pushed the ParallelScan branch 2 times, most recently from 02b7a4d to edf95dd Compare September 6, 2023 16:26
@artemcm
Copy link
Contributor Author

artemcm commented Sep 6, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Sep 6, 2023

@swift-ci test Windows platform

@artemcm artemcm marked this pull request as ready for review September 6, 2023 19:20
@artemcm artemcm requested review from xymus, nkcsgexi and elsh September 6, 2023 19:20
@artemcm artemcm changed the title [[Dependency Scanning] Implement parallel imported module resolution [Dependency Scanning] Implement parallel imported module resolution Sep 6, 2023
@artemcm
Copy link
Contributor Author

artemcm commented Sep 7, 2023

Windows build is failing to build the refactor because we're not linking something in correctly when building SwiftIDETests. 🤔

swiftSerialization.lib(ModuleDependencyScanner.cpp.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl swift::FrontendOptions::shouldTrackSystemDependencies(void)const " (?shouldTrackSystemDependencies@FrontendOptions@swift@@QEBA_NXZ) referenced in function "public: __cdecl swift::ModuleDependencyScanningWorker::ModuleDependencyScanningWorker(class swift::SwiftDependencyScanningService &,class swift::CompilerInvocation const &,class swift::SILOptions const &,class swift::ASTContext &,class swift::DependencyTracker &,class swift::DiagnosticEngine &)" (??0ModuleDependencyScanningWorker@swift@@QEAA@AEAVSwiftDependencyScanningService@1@AEBVCompilerInvocation@1@AEBVSILOptions@1@AEAVASTContext@1@AEAVDependencyTracker@1@AEAVDiagnosticEngine@1@@Z)

@artemcm
Copy link
Contributor Author

artemcm commented Sep 7, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Sep 7, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Sep 7, 2023

@swift-ci test

@@ -0,0 +1,150 @@
//===--- ModuleDependencyScanner.h - Import Swift modules --------*- C++
//-*-===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@artemcm
Copy link
Contributor Author

artemcm commented Sep 21, 2023

@swift-ci test

…pendencyScanner' class

From being a scattered collection of 'static' methods in ScanDependencies.cpp
and member methods of ASTContext. This makes 'ScanDependencies.cpp' much easier
to read, and abstracts the actual scanning logic away to a place with common
state which will make it easier to reason about in the future.
'ModuleDependencyScanner' maintains a Thread Pool along with a pool of workers
which are capable of executing a filesystem lookup of a named module dependency.
When resolving imports of a given Swift module, each import's resolution
operation can be issued asunchronously.
@artemcm
Copy link
Contributor Author

artemcm commented Sep 22, 2023

@swift-ci test

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

Successfully merging this pull request may close these issues.

2 participants