aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ModuleManager.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-10-22 15:08:02 -0700
committerGitHub <noreply@github.com>2024-10-22 15:08:02 -0700
commit0ffa29fe8152e247eea87017e8c5aeedc6329c15 (patch)
tree1381ae274759d08bae5435f2095bcb1e357164c0 /clang/lib/Serialization/ModuleManager.cpp
parentd98519715617a462c3ebadc778558b717354b6d2 (diff)
downloadllvm-0ffa29fe8152e247eea87017e8c5aeedc6329c15.zip
llvm-0ffa29fe8152e247eea87017e8c5aeedc6329c15.tar.gz
llvm-0ffa29fe8152e247eea87017e8c5aeedc6329c15.tar.bz2
[clang][modules] Timestamp PCM files when writing (#112452)
Clang uses timestamp files to track the last time an implicitly-built PCM file was verified to be up-to-date with regard to its inputs. With `-fbuild-session-{file,timestamp}=` and `-fmodules-validate-once-per-build-session` this reduces the number of times a PCM file is checked per "build session". The behavior I'm seeing with the current scheme is that when lots of Clang instances wait for the same PCM to be built, they race to validate it as soon as the file lock gets released, causing lots of concurrent IO. This patch makes it so that the timestamp is written by the same Clang instance responsible for building the PCM while still holding the lock. This makes it so that whenever a PCM file gets compiled, it's never re-validated in the same build session. I believe this is as sound as the current scheme. One thing to be aware of is that there might be a time interval between accessing input file N and writing the timestamp file, where changes to input files 0..<N would not result in a rebuild. Since this is the case current scheme too, I'm not too concerned about that. I've seen this speed up `clang-scan-deps` by ~27%.
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index e74a16b..ba78c9e 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -170,7 +170,8 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
NewModule->InputFilesValidationTimestamp = 0;
if (NewModule->Kind == MK_ImplicitModule) {
- std::string TimestampFilename = NewModule->getTimestampFilename();
+ std::string TimestampFilename =
+ ModuleFile::getTimestampFilename(NewModule->FileName);
llvm::vfs::Status Status;
// A cached stat value would be fine as well.
if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))