Skip to content

[clang][deps] Cache VFS::getRealPath() and VFS::exists() #8571

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 8 commits into from
Apr 15, 2024

Conversation

jansvoboda11
Copy link

Cherry-pick of llvm#68645, llvm#88152 and related NFC commits

Explanation: The dependency scanner caches file system accesses under the assumption that input files are immutable. This PR adds caching of the VFS::getRealPath() and VFS::exists() calls in order to reduce file system traffic and increase performance.

Risk: Low. This is a performance optimization.

Testing: New unit tests were added for the implemented caching behavior.

Reviewed By: @benlangmuir, @jansvoboda11

jansvoboda11 and others added 8 commits April 12, 2024 12:56
This is an NFC change split from llvm#68645.

(cherry picked from commit fe59cb2)
This is an NFC change split from llvm#68645.

(cherry picked from commit edd7fed)
This is an NFC change split from llvm#68645.

(cherry picked from commit c11976f)
This PR starts caching calls to
`DependencyScanningWorkerFilesystem::getRealPath()` that we use whenever
we canonicalize module map path. In the case of the real VFS, this
functions performs an expensive syscall that we'd like to do as rarely
as possible.

This PR keeps the real path out of `CachedFileSystemEntry`, since that's
**immutable**; populating the real path on creation of this data
structure (every stat/open) would be expensive.

(cherry picked from commit a11a432)
Caused by commit edd7fed

(cherry picked from commit 446d38c)
…esystem` to have it use cached `status` (llvm#88152)

As-is, calls to `exists()` fallback on the implementation in
`ProxyFileSystem::exists` which explicitly calls out to the underlying
`FS`, which for the `DependencyScanningFilesystem` (overlay) is the real
underlying filesystem.

Instead, directly overloading `exists` allows us to have it rely on the
cached `status` behavior used elsewhere by the
`DependencyScanningFilesystem`.

(cherry picked from commit 779ba60)
@jansvoboda11 jansvoboda11 requested a review from nkcsgexi April 12, 2024 22:05
@jansvoboda11
Copy link
Author

@swift-ci please 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.

3 participants