13 Commits

Author SHA1 Message Date
Qiongsi Wu
5c08bfa23a
[clang][Dependency Scanning] Report only Regular File Size Changes When Computing Out-of-Date File System Cache Entries (#148082)
We noticed that when a directory's content changes, its size reported by
`status` can change as well. We do not want to include such "false
positive" cases. This PR revises the computation so that only regular
file size changes are considered out-of-date.

rdar://152247357
2025-07-11 09:46:46 -07:00
Qiongsi Wu
51d1385cdf
[clang Dependency Scanning] Enhance File Caching Diagnostics (#144105)
`DependencyScanningFileSystemSharedCache` can currently report
out-of-date negatively stat cached paths. This PR enhances the reporting
with two modifications.

1. The reported path are now null terminated char arrays instead of
`StringRef`s. This way the API's user can avoid copying `StringRef`s to
other containers because the char arrays can be used directly.
2. The API now reports out-of-date cache entry due to file size changes.
Specifically, we check each file's cached size against the size of the
same file on the underlying FS. If the sizes are different, diagnostics
will be reported.

rdar://152247357
2025-06-24 15:48:39 -07:00
Qinkun Bao
43d042b350
Revert "[clang][scan-deps] Add option to disable caching stat failures" (#145528)
Reverts llvm/llvm-project#144000

First buildbot failure:
https://lab.llvm.org/buildbot/#/builders/164/builds/11064
2025-06-24 11:12:05 -04:00
Michael Spencer
6110dead89
[clang][scan-deps] Add option to disable caching stat failures (#144000)
While the source code isn't supposed to change during a build, in some
environments it does. This adds an option that disables caching of stat
failures, meaning that source files can be added to the build during
scanning.

This adds a `-no-cache-negative-stats` option to clang-scan-deps to
enable this behavior. There are no tests for clang-scan-deps as there's
no reliable way to do so from it. A unit test has been added that
modifies the filesystem between scans to test it.
2025-06-20 13:28:05 -07:00
Kazu Hirata
ac9b7788de
[Tooling] Remove a redundant call to std::unique_ptr<T>::get (NFC) (#139431) 2025-05-10 22:51:06 -07:00
Qiongsi Wu
2017831d44
[clang][Unit Test] Updating Negative Stat Caching Diagnostic Unit Test (#138955)
This PR makes a minor modification to make it more stable. The only
change is adding a suffix to the path under test.

rdar://149147920
2025-05-08 08:49:11 -07:00
Qiongsi Wu
9ef91677a4
[clang][Dependency Scanning] Adding an API to Diagnose Invalid Negative Stat Cache Entries (#135703)
We have had numerous situations where the negatively stat cached paths
are invalidated during the build, and such invalidations lead to build
errors.

This PR adds an API to diagnose such cases.
`DependencyScanningFilesystemSharedCache::diagnoseNegativeStatCachedPaths`
allows users of the cache to ask the cache to examine all negatively
stat cached paths, and re-stat the paths using the passed-in file
system. If any re-stat succeeds, the API emits diagnostics.

rdar://149147920
2025-04-18 10:52:39 -07:00
Jan Svoboda
92cd66d905 [clang][deps][test] Update reference to tracing VFS
This fixes build failure introduced by 70fcdb3d52272eba96d4b268d334826690524f50.
2024-09-06 14:29:44 -07:00
Jan Svoboda
70fcdb3d52
[llvm][support] Implement tracing virtual file system (#88326)
LLVM-based tools often use the `llvm::vfs::FileSystem` instrastructure
to access the file system. This patch adds new kind of a VFS that
performs lightweight tracing of file system operations on an underlying
VFS. This is supposed to aid in investigating file system traffic
without resorting to instrumentation on the operating system level.
There will be follow-up patches that integrate this into Clang and its
dependency scanner.
2024-09-06 14:14:44 -07:00
Jan Svoboda
55323ca6c8
[clang][deps] Only bypass scanning VFS for the module cache (#88800)
The scanning VFS doesn't cache stat failures of paths with no extension.
This was originally implemented to avoid caching the non-existence of
the modules cache directory that the modular scanner will eventually
create if it does not exist.

However, this prevents caching of the non-existence of all directories
and notably also header files from the standard C++ library, which can
lead to sub-par performance.

This patch adds an API to the scanning VFS that allows clients to
configure path prefix for which to bypass the scanning VFS and use the
underlying VFS directly.
2024-08-13 08:41:39 -07:00
Artem Chikin
779ba60417
[clang][deps] Overload Filesystem::exists in DependencyScanningFilesystem to have it use cached status (#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`.
2024-04-12 14:46:56 -07:00
Jan Svoboda
a9111d4a26 [clang] Remove unused variable in test 2024-04-12 12:37:11 -07:00
Jan Svoboda
a11a4324bb
[clang][deps] Cache VFS::getRealPath() (#68645)
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.
2024-04-12 10:34:42 -07:00