From d33ee60d94b4d228d006b4a9f067489ac4ff32e0 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 16 Jan 2024 18:11:18 +0100 Subject: Keep implied target-cache values alive ... by uplinking them appropriately. --- src/buildtool/storage/target_cache.hpp | 5 +++++ src/buildtool/storage/target_cache.tpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp index f263fdf9..385d1cd0 100644 --- a/src/buildtool/storage/target_cache.hpp +++ b/src/buildtool/storage/target_cache.hpp @@ -123,6 +123,11 @@ class TargetCache { /*kSetEpochTime=*/false> file_store_; + template + requires(kIsLocalGeneration) [[nodiscard]] auto LocalUplinkEntry( + LocalGenerationTC const& latest, + std::string const& key_digest) const noexcept -> bool; + [[nodiscard]] static auto ComputeShard() noexcept -> std::string { return ArtifactDigest::Create( StorageConfig::ExecutionBackendDescription()) diff --git a/src/buildtool/storage/target_cache.tpp b/src/buildtool/storage/target_cache.tpp index d1c9d01c..cd56ef59 100644 --- a/src/buildtool/storage/target_cache.tpp +++ b/src/buildtool/storage/target_cache.tpp @@ -87,8 +87,15 @@ requires(kIsLocalGeneration) auto TargetCache< kDoGlobalUplink>::LocalUplinkEntry(LocalGenerationTC const& latest, TargetCacheKey const& key) const noexcept -> bool { + return LocalUplinkEntry(latest, key.Id().digest.hash()); +} + +template +template +requires(kIsLocalGeneration) auto TargetCache:: + LocalUplinkEntry(LocalGenerationTC const& latest, + std::string const& key_digest) const noexcept -> bool { // Determine target cache key path of given generation. - auto key_digest = key.Id().digest.hash(); if (FileSystemManager::IsFile(latest.file_store_.GetPath(key_digest))) { return true; } @@ -125,6 +132,16 @@ requires(kIsLocalGeneration) auto TargetCache< return false; } auto entry = TargetCacheEntry::FromJson(json_desc); + + // Uplink the implied export targets first + for (auto const& implied_digest : entry.ToImplied()) { + if (implied_digest != key_digest) { + if (not LocalUplinkEntry(latest, implied_digest)) { + return false; + } + } + } + std::vector artifacts_info; if (not entry.ToArtifacts(&artifacts_info)) { return false; -- cgit v1.2.3