[clang][deps] Only cache files with specific extension
authorJan Svoboda <jan_svoboda@apple.com>
Fri, 17 Mar 2023 20:19:12 +0000 (13:19 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Mon, 20 Mar 2023 18:12:00 +0000 (11:12 -0700)
commitd1e00b6f136ec71a4c95a7eb4fd81ec0ab547962
tree4e17d503129980d126757ebcfa162da2b6c4585c
parent0c0468e6df2bcabd207858891c2387357857b0bc
[clang][deps] Only cache files with specific extension

In the scanner's VFS, we cache all files by default and only avoid caching stat failures for certain files. This tanks the performance of scanning with pre-populated module cache. When there is a stale PCM file, it gets cached by the scanner at the start and the rebuilt version never makes it through the VFS again. The TU invocation that rebuilds the PCM only sees the copy in its InMemoryModuleCache, which is invisible to other invocations. This means the PCM gets rebuilt for every TU given to the scanner.

This patch fixes the situation by flipping the default, only caching files that are known to be important, and letting everything else fall through to the underlying VFS.

rdar://106376153

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D146328
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
clang/unittests/Tooling/DependencyScannerTest.cpp