[clang] [clang][Modules] Refresh a module file's access time when it is read (PR #239747)
Qiongsi Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 6 14:56:36 PST 2026
================
@@ -200,6 +202,36 @@ std::error_code clang::writeImpl(StringRef Path, llvm::MemoryBufferRef Buffer,
return {};
}
+/// The access time of a module file is only refreshed explicitly when it is
+/// older than this interval so we avoid frequent yet unnecessary updates.
+static constexpr std::chrono::seconds AccessTimeRefreshInterval(60);
+
+/// Record that the module file open as \p FD has just been used by bringing
+/// its access time up to date, so we can prune the pcms by access time more
+/// reliably. Usually modules are mmapped, and on some systems (e.g., macOS)
+/// mmapping a file updates its access time. When a module is read rather than
+/// mmapped, or the file system updates access times lazily (e.g., Linux
+/// relatime) or not at all (noatime), this closes the gap. Not implemented on
+/// Windows.
+static void refreshAccessTime([[maybe_unused]] llvm::sys::fs::file_t FD) {
+#ifndef _WIN32
----------------
qiongsiwu wrote:
Implementing this on Windows is not hard but also not straightforward, because files need to be opened differently. I added a FIXME and will follow up.
https://github.com/llvm/llvm-project/pull/239747
More information about the cfe-commits
mailing list