-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Dependency Scanning][Refactor] Reduce the number of ClangImporter
instances used by the scanner
#81361
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
634bafc
to
92632e6
Compare
@swift-ci test |
… scanning worker Move relevant logic directly into the worker
…r textual interface scanning sub-instance
92632e6
to
5b13c94
Compare
|
||
// When caching is enabled, we rely on ClangImporter for | ||
// 'addClangInvovcationDependencies' | ||
if (Invocation.getCASOptions().EnableCaching) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @cachemeifyoucan
This is due to:
swift/lib/Serialization/ScanningLoaders.cpp
Line 248 in df32362
auto clangImporter = |
I imagine we ought to be able to factor that out to something that happens once at worker creation, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling that I might be able to remove that function now. Let me check (Oh, there was a bad typo in function name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a draft: #81389
I need to do more clean up before commit that PR, will comment in that PR about background
@swift-ci test |
@swift-ci test Linux platform |
This is a refactoring PR that includes two changes meant to reduce the overall number of times that
ClangImporter
is instantiated during a given dependency scanning action:Remove 'ClangImporter' instance from dependency scanning worker
This change moves
getModuleDependency
andgetHeaderDependency
functionality fromClangImporter
directly into Swift'sModuleDependencyScanningWorker
using theclangScanningTool
it already has, removing the need to instantiate an instance ofClangImporter
per-worker.Reduce number of module loaders instantiated for textual interface scanning sub-instance
When creating a compilation sub-instance for scanning a textual Swift module interface for dependencies, in
setupModuleLoaders
only configure the strictly-necessary module loaders, skippingClangImporter
in particular.On a large benchmark scan (e.g. importing every Swift module in the macOS SDK yielding ~270 Swift modules and ~530 Clang modules) this change results in a ~5% speedup.