Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented May 7, 2025

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 and getHeaderDependency functionality from ClangImporter directly into Swift's ModuleDependencyScanningWorker using the clangScanningTool it already has, removing the need to instantiate an instance of ClangImporter 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, skipping ClangImporter 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.

@artemcm
Copy link
Contributor Author

artemcm commented May 7, 2025

@swift-ci test

@artemcm artemcm force-pushed the DepScanFewerClangs branch from 634bafc to 92632e6 Compare May 7, 2025 22:22
@artemcm
Copy link
Contributor Author

artemcm commented May 7, 2025

@swift-ci test

artemcm added 2 commits May 7, 2025 16:43
… scanning worker

Move relevant logic directly into the worker
@artemcm artemcm force-pushed the DepScanFewerClangs branch from 92632e6 to 5b13c94 Compare May 7, 2025 23:48

// When caching is enabled, we rely on ClangImporter for
// 'addClangInvovcationDependencies'
if (Invocation.getCASOptions().EnableCaching) {
Copy link
Contributor Author

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:

auto clangImporter =

I imagine we ought to be able to factor that out to something that happens once at worker creation, too.

Copy link
Contributor

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)

Copy link
Contributor

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

@artemcm
Copy link
Contributor Author

artemcm commented May 7, 2025

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented May 8, 2025

@swift-ci test Linux platform

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