aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-09-11 16:04:56 -0700
committerGitHub <noreply@github.com>2024-09-11 16:04:56 -0700
commit6e4dcbb21dab47e520f2cd19e7017af27328669e (patch)
treea363bfba4ad87c546aa6378e879496baa0185dad /clang/lib/Basic/FileManager.cpp
parentd32982b6b3753091a532530c7a66f9686deb5233 (diff)
downloadllvm-6e4dcbb21dab47e520f2cd19e7017af27328669e.zip
llvm-6e4dcbb21dab47e520f2cd19e7017af27328669e.tar.gz
llvm-6e4dcbb21dab47e520f2cd19e7017af27328669e.tar.bz2
[clang][deps] Print tracing VFS data (#108056)
Clang's `-cc1 -print-stats` shows lots of useful internal data including basic `FileManager` stats. Since this layer caches some results, it is unclear how that information translates to actual filesystem accesses. This PR uses `llvm::vfs::TracingFileSystem` to provide that missing information. Similar mechanism is implemented for `clang-scan-deps`'s verbose mode (`-v`). IO contention proved to be a real bottleneck a couple of times already and this new feature should make those easier to detect in the future. The tracing VFS is inserted below the caching FS and above the real FS.
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r--clang/lib/Basic/FileManager.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 4509cee..6097b85 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -692,5 +692,16 @@ void FileManager::PrintStats() const {
llvm::errs() << NumFileLookups << " file lookups, "
<< NumFileCacheMisses << " file cache misses.\n";
+ getVirtualFileSystem().visit([](llvm::vfs::FileSystem &VFS) {
+ if (auto *T = dyn_cast_or_null<llvm::vfs::TracingFileSystem>(&VFS))
+ llvm::errs() << "\n*** Virtual File System Stats:\n"
+ << T->NumStatusCalls << " status() calls\n"
+ << T->NumOpenFileForReadCalls << " openFileForRead() calls\n"
+ << T->NumDirBeginCalls << " dir_begin() calls\n"
+ << T->NumGetRealPathCalls << " getRealPath() calls\n"
+ << T->NumExistsCalls << " exists() calls\n"
+ << T->NumIsLocalCalls << " isLocal() calls\n";
+ });
+
//llvm::errs() << PagesMapped << BytesOfPagesMapped << FSLookups;
}