From 24c900225902337feee7a8cc4399fdffdecd945f Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 9 Jul 2024 17:44:45 +0200 Subject: TargetCache: Use StorageConfig instance for sharding Instead of computing the shard based on the RemoteExecutionConfig singleton, use the already computed hash stored in the passed StorageConfig instance, which now needs to be set up separately if bootstrapping in order to avoid unwanted includes. Storing the backend description to CAS and corresponding audit checks now take place in main. --- src/buildtool/storage/target_cache.hpp | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'src/buildtool/storage/target_cache.hpp') diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp index e5a64737..2f52e100 100644 --- a/src/buildtool/storage/target_cache.hpp +++ b/src/buildtool/storage/target_cache.hpp @@ -27,7 +27,6 @@ #include "src/buildtool/build_engine/base_maps/entity_name_data.hpp" #include "src/buildtool/build_engine/expression/configuration.hpp" #include "src/buildtool/common/artifact.hpp" -#include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/file_system/file_storage.hpp" #include "src/buildtool/file_system/object_type.hpp" #include "src/buildtool/logging/logger.hpp" @@ -36,7 +35,6 @@ #include "src/buildtool/storage/target_cache_entry.hpp" #include "src/buildtool/storage/target_cache_key.hpp" #include "src/buildtool/storage/uplinker.hpp" -#include "src/utils/cpp/gsl.hpp" /// \brief The high-level target cache for storing export target's data. /// Supports global uplinking across all generations. The uplink is @@ -58,16 +56,10 @@ class TargetCache { GenerationConfig const& config, gsl::not_null const*> const& uplinker) : cas_{*cas}, - file_store_{config.target_cache / ComputeShard()}, + file_store_{config.target_cache / + config.storage_config->backend_description_id}, uplinker_{*uplinker}, - explicit_shard_{std::nullopt} { - if constexpr (kDoGlobalUplink) { - // write backend description (shard) to CAS - [[maybe_unused]] auto id = - cas_.StoreBlob(RemoteExecutionConfig::DescribeBackend()); - EnsuresAudit(id and ArtifactDigest{*id}.hash() == ComputeShard()); - } - } + explicit_shard_{std::nullopt} {} /// \brief Returns a new TargetCache backed by the same CAS, but the /// FileStorage uses the given \p shard. This is particularly useful for the @@ -152,12 +144,6 @@ class TargetCache { LocalGenerationTC const& latest, std::string const& key_digest) const noexcept -> bool; - [[nodiscard]] static auto ComputeShard() noexcept -> std::string { - return ArtifactDigest::Create( - RemoteExecutionConfig::DescribeBackend()) - .hash(); - } - [[nodiscard]] auto DownloadKnownArtifacts( TargetCacheEntry const& value, ArtifactDownloader const& downloader) const noexcept -> bool; -- cgit v1.2.3