[clang] [llvm] [clang][deps] Add in-flight query caching to `DependencyScanningFilesystemSharedCache` (PR #199680)
Artem Chikin via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 03:58:08 PDT 2026
================
@@ -152,19 +154,54 @@ using CachedRealPath = llvm::ErrorOr<std::string>;
/// the worker threads.
class DependencyScanningFilesystemSharedCache {
public:
+ /// Tracks a cache entry whose value is currently being computed by one
+ /// worker so that other workers arriving at the same key can wait for the
+ /// result rather than producing it in parallel. The producer publishes the
+ /// resolved entry into \c Result, sets \c Done, and notifies waiters via
+ /// \c CondVar. Waiters synchronize through the owning shard's \c CacheLock.
+ struct InProgressEntry {
+ std::condition_variable CondVar;
+ bool Done = false;
+ const CachedFileSystemEntry *Result = nullptr;
----------------
artemcm wrote:
`Result` does duplicate the value, but it's the one copy a woken waiter can read without re-taking the shard lock, which I think is still net beneficial, especially in combination with the above refactor to move away from using the shard lock on the wait.
https://github.com/llvm/llvm-project/pull/199680
More information about the cfe-commits
mailing list