Skip to content

[Dependency Scanning] Use a standalone DependencyScanningFilesystemon the scanner, sharing a common status cache from Clang's dependency service cache #72932

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 1 commit into from
Apr 10, 2024

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Apr 9, 2024

Built-in Clang dependency scanner uses a DependencyScanningFilesystem which relies on the stat cache owned by its parent DependencyScanningService. This way repeated attempts to query a filesystem entry hit the cache during scanning. Until now, the Swift scanner did not share this stat cache so filesystem entry lookups by the Swift scanner went directly to the "real" underlying filesystem, resulting in often duplicated calls to stat. This change makes the Swift scanner use/share Clang Scanner's stat cache, unifying the filesystem abstraction for the two.

@artemcm artemcm force-pushed the UseClangStatCacheForScanningFS branch from 591b024 to 8ca0a1d Compare April 9, 2024 17:12
@artemcm
Copy link
Contributor Author

artemcm commented Apr 9, 2024

@swift-ci test

@artemcm artemcm force-pushed the UseClangStatCacheForScanningFS branch from 8ca0a1d to 3427209 Compare April 9, 2024 18:08
@artemcm
Copy link
Contributor Author

artemcm commented Apr 9, 2024

@swift-ci test

new clang::tooling::dependencies::DependencyScanningWorkerFilesystem(
globalScanningService.ClangScanningService->getSharedCache(),
ScanASTContext.SourceMgr.getFileSystem());
ScanASTContext.SourceMgr.setFileSystem(std::move(DepFS));
Copy link
Contributor

@jansvoboda11 jansvoboda11 Apr 9, 2024

Choose a reason for hiding this comment

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

What's the lifetime of ScanASTContext?

I'm asking because each instance of DependencyScanningWorkerFilesystem has a copy of a subset of the shared cache to reduce lock contention in the shared cache. We should create as few of these VFSs as possible in order to avoid re-populating the local cache from the shared cache over and over again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its lifetime is the entire scan. And until we enable parallel-scanning by-default, there is only one of these workers.

… on the scanner, sharing a common `status` cache from Clang's dependency service cache
@artemcm artemcm force-pushed the UseClangStatCacheForScanningFS branch from 3427209 to 1804a84 Compare April 9, 2024 20:36
@artemcm
Copy link
Contributor Author

artemcm commented Apr 9, 2024

@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.

4 participants