diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2022-12-13 20:32:15 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2022-12-13 20:38:38 +0100 |
commit | 63e2517d39e679c0f8d23cac54311406d3ca243b (patch) | |
tree | eb32be439343b68265831fab7241fe05ca340ae8 /src | |
parent | 5d00143e447a50ef9f4709e685c9f0776431c00b (diff) | |
download | ccache-63e2517d39e679c0f8d23cac54311406d3ca243b.tar.gz |
fix: Fix reporting of local/remote cache misses in depend mode
Diffstat (limited to 'src')
-rw-r--r-- | src/ccache.cpp | 5 | ||||
-rw-r--r-- | src/storage/Storage.cpp | 5 | ||||
-rw-r--r-- | src/storage/local/LocalStorage.cpp | 5 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/ccache.cpp b/src/ccache.cpp index c063a58f..8791f788 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -631,6 +631,11 @@ process_preprocessed_file(Context& ctx, Hash& hash, const std::string& path) static std::optional<Digest> result_key_from_depfile(Context& ctx, Hash& hash) { + // Make sure that result hash will always be different from the manifest hash + // since there otherwise may a storage key collision (in case the dependency + // file is empty). + hash.hash_delimiter("result"); + const auto file_content = util::read_file<std::string>(ctx.args_info.output_dep); if (!file_content) { diff --git a/src/storage/Storage.cpp b/src/storage/Storage.cpp index 5c843db2..da707ea6 100644 --- a/src/storage/Storage.cpp +++ b/src/storage/Storage.cpp @@ -463,6 +463,11 @@ Storage::get_from_remote_storage(const Digest& key, local.increment_statistic(core::Statistic::remote_storage_read_miss); if (type == core::CacheEntryType::result) { local.increment_statistic(core::Statistic::remote_storage_miss); + } else if (m_config.depend_mode()) { + // With the depend mode enabled, a missing manifest means that we can't + // even try to look up a result, so note the miss already now. + ASSERT(type == core::CacheEntryType::manifest); + local.increment_statistic(core::Statistic::remote_storage_miss); } } } diff --git a/src/storage/local/LocalStorage.cpp b/src/storage/local/LocalStorage.cpp index 274a4460..f1984caa 100644 --- a/src/storage/local/LocalStorage.cpp +++ b/src/storage/local/LocalStorage.cpp @@ -223,6 +223,11 @@ LocalStorage::get(const Digest& key, const core::CacheEntryType type) if (type == core::CacheEntryType::result) { increment_statistic(return_value ? core::Statistic::local_storage_hit : core::Statistic::local_storage_miss); + } else if (m_config.depend_mode() && !return_value) { + // With the depend mode enabled, a missing manifest means that we can't even + // try to look up a result, so note the miss already now. + ASSERT(type == core::CacheEntryType::manifest); + increment_statistic(core::Statistic::local_storage_miss); } return return_value; |