summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/storage/garbage_collector.cpp89
-rw-r--r--src/buildtool/storage/garbage_collector.hpp51
-rw-r--r--src/buildtool/storage/large_object_cas.hpp11
-rw-r--r--src/buildtool/storage/large_object_cas.tpp5
-rw-r--r--src/buildtool/storage/local_ac.hpp17
-rw-r--r--src/buildtool/storage/local_ac.tpp5
-rw-r--r--src/buildtool/storage/local_cas.hpp41
-rw-r--r--src/buildtool/storage/storage.hpp53
-rw-r--r--src/buildtool/storage/target_cache.hpp15
-rw-r--r--src/buildtool/storage/target_cache.tpp6
10 files changed, 70 insertions, 223 deletions
diff --git a/src/buildtool/storage/garbage_collector.cpp b/src/buildtool/storage/garbage_collector.cpp
index 76a225c3..45237413 100644
--- a/src/buildtool/storage/garbage_collector.cpp
+++ b/src/buildtool/storage/garbage_collector.cpp
@@ -16,27 +16,19 @@
#include "src/buildtool/storage/garbage_collector.hpp"
-#include <cstddef>
#include <filesystem>
#include <memory>
#include <vector>
#include "nlohmann/json.hpp"
#include "src/buildtool/common/artifact.hpp"
-#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
-#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/execution_api/common/message_limits.hpp"
-#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
-#include "src/buildtool/file_system/git_repo.hpp"
-#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/compactifier.hpp"
#include "src/buildtool/storage/storage.hpp"
-#include "src/buildtool/storage/target_cache_entry.hpp"
-#include "src/utils/cpp/hex_string.hpp"
namespace {
@@ -59,87 +51,6 @@ auto RemoveDirs(const std::vector<std::filesystem::path>& directories) -> bool {
} // namespace
-auto GarbageCollector::GlobalUplinkBlob(bazel_re::Digest const& digest,
- bool is_executable) noexcept -> bool {
- // Try to find blob in all generations.
- auto const& latest_cas = Storage::Generation(0).CAS();
- for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations();
- ++i) {
- // Note that we uplink with _skip_sync_ as we want to prefer hard links
- // from older generations over copies from the companion file/exec CAS.
- if (Storage::Generation(i).CAS().LocalUplinkBlob(
- latest_cas,
- digest,
- is_executable,
- /*skip_sync=*/true,
- /*splice_result=*/true)) {
- return true;
- }
- }
- return false;
-}
-
-auto GarbageCollector::GlobalUplinkLargeBlob(
- bazel_re::Digest const& digest) noexcept -> bool {
- // Try to find large entry in all generations.
- auto const& latest_cas = Storage::Generation(0).CAS();
- for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations();
- ++i) {
- if (Storage::Generation(i)
- .CAS()
- .LocalUplinkLargeObject<ObjectType::File>(latest_cas, digest)) {
- return true;
- }
- }
- return false;
-}
-
-auto GarbageCollector::GlobalUplinkTree(bazel_re::Digest const& digest) noexcept
- -> bool {
- // Try to find tree in all generations.
- auto const& latest_cas = Storage::Generation(0).CAS();
- for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations();
- ++i) {
- if (Storage::Generation(i).CAS().LocalUplinkTree(
- latest_cas, digest, /*splice_result=*/true)) {
- return true;
- }
- }
- return false;
-}
-
-auto GarbageCollector::GlobalUplinkActionCacheEntry(
- bazel_re::Digest const& action_id) noexcept -> bool {
- // Try to find action-cache entry in all generations.
- auto const& latest_ac = Storage::Generation(0).ActionCache();
- for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations();
- ++i) {
- if (Storage::Generation(i).ActionCache().LocalUplinkEntry(latest_ac,
- action_id)) {
- return true;
- }
- }
- return false;
-}
-
-auto GarbageCollector::GlobalUplinkTargetCacheEntry(
- TargetCacheKey const& key,
- std::optional<std::string> const& shard) noexcept -> bool {
- // Try to find target-cache entry in all generations.
- auto const& latest_tc =
- Storage::Generation(0).TargetCache().WithShard(shard);
- for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations();
- ++i) {
- if (Storage::Generation(i)
- .TargetCache()
- .WithShard(shard)
- .LocalUplinkEntry(latest_tc, key)) {
- return true;
- }
- }
- return false;
-}
-
auto GarbageCollector::SharedLock(StorageConfig const& storage_config) noexcept
-> std::optional<LockFile> {
return LockFile::Acquire(LockFilePath(storage_config), /*is_shared=*/true);
diff --git a/src/buildtool/storage/garbage_collector.hpp b/src/buildtool/storage/garbage_collector.hpp
index 86486d48..577e878d 100644
--- a/src/buildtool/storage/garbage_collector.hpp
+++ b/src/buildtool/storage/garbage_collector.hpp
@@ -23,59 +23,10 @@
#include "src/buildtool/storage/config.hpp"
#include "src/utils/cpp/file_locking.hpp"
-// forward declarations
-namespace build::bazel::remote::execution::v2 {
-class Digest;
-}
-namespace bazel_re = build::bazel::remote::execution::v2;
-class TargetCacheKey;
-
/// \brief Global garbage collector implementation.
-/// Responsible for deleting oldest generation and uplinking across all
-/// generations to latest generation.
+/// Responsible for deleting oldest generation.
class GarbageCollector {
public:
- /// \brief Uplink blob across LocalCASes from all generations to latest.
- /// Note that blobs will NOT be synced between file/executable CAS.
- /// \param digest Digest of the blob to uplink.
- /// \param is_executable Indicate that blob is an executable.
- /// \returns true if blob was found and successfully uplinked.
- [[nodiscard]] auto static GlobalUplinkBlob(bazel_re::Digest const& digest,
- bool is_executable) noexcept
- -> bool;
-
- /// \brief Uplink large blob entry across LocalCASes from all generations to
- /// latest. This method does not splice the large object.
- /// \param digest Digest of the large blob entry to uplink.
- /// \returns true if large entry was found and successfully uplinked.
- [[nodiscard]] auto static GlobalUplinkLargeBlob(
- bazel_re::Digest const& digest) noexcept -> bool;
-
- /// \brief Uplink tree across LocalCASes from all generations to latest.
- /// Note that the tree will be deeply uplinked, i.e., all entries referenced
- /// by this tree will be uplinked before (including sub-trees).
- /// \param digest Digest of the tree to uplink.
- /// \returns true if tree was found and successfully uplinked (deep).
- [[nodiscard]] auto static GlobalUplinkTree(
- bazel_re::Digest const& digest) noexcept -> bool;
-
- /// \brief Uplink entry from action cache across all generations to latest.
- /// Note that the entry will be uplinked including all referenced items.
- /// \param action_id Id of the action to uplink entry for.
- /// \returns true if cache entry was found and successfully uplinked.
- [[nodiscard]] auto static GlobalUplinkActionCacheEntry(
- bazel_re::Digest const& action_id) noexcept -> bool;
-
- /// \brief Uplink entry from target cache across all generations to latest.
- /// Note that the entry will be uplinked including all referenced items.
- /// \param key Target cache key to uplink entry for.
- /// \param shard Optional explicit shard, if the default is not intended.
- /// \returns true if cache entry was found and successfully uplinked.
- [[nodiscard]] auto static GlobalUplinkTargetCacheEntry(
- TargetCacheKey const& key,
- std::optional<std::string> const& shard = std::nullopt) noexcept
- -> bool;
-
/// \brief Trigger garbage collection; unless no_rotation is given, this
/// will include rotation of generations and deleting the oldest generation.
/// \returns true on success.
diff --git a/src/buildtool/storage/large_object_cas.hpp b/src/buildtool/storage/large_object_cas.hpp
index e442aa90..70f1e7d8 100644
--- a/src/buildtool/storage/large_object_cas.hpp
+++ b/src/buildtool/storage/large_object_cas.hpp
@@ -25,6 +25,7 @@
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/object_type.hpp"
#include "src/buildtool/storage/config.hpp"
+#include "src/buildtool/storage/uplinker.hpp"
#include "src/utils/cpp/expected.hpp"
#include "src/utils/cpp/tmp_dir.hpp"
@@ -98,11 +99,14 @@ class LargeObjectCAS final {
public:
explicit LargeObjectCAS(
gsl::not_null<LocalCAS<kDoGlobalUplink> const*> const& local_cas,
- GenerationConfig const& config) noexcept
+ GenerationConfig const& config,
+ gsl::not_null<Uplinker<kDoGlobalUplink> const*> const&
+ uplinker) noexcept
: local_cas_(*local_cas),
+ storage_config_{*config.storage_config},
+ uplinker_{*uplinker},
file_store_(IsTreeObject(kType) ? config.cas_large_t
- : config.cas_large_f),
- storage_config_{*config.storage_config} {}
+ : config.cas_large_f) {}
LargeObjectCAS(LargeObjectCAS const&) = delete;
LargeObjectCAS(LargeObjectCAS&&) = delete;
@@ -172,6 +176,7 @@ class LargeObjectCAS final {
LocalCAS<kDoGlobalUplink> const& local_cas_;
StorageConfig const& storage_config_;
+ Uplinker<kDoGlobalUplink> const& uplinker_;
FileStorage<ObjectType::File, kStoreMode, /*kSetEpochTime=*/false>
file_store_;
diff --git a/src/buildtool/storage/large_object_cas.tpp b/src/buildtool/storage/large_object_cas.tpp
index ca8ac8c0..0f79b231 100644
--- a/src/buildtool/storage/large_object_cas.tpp
+++ b/src/buildtool/storage/large_object_cas.tpp
@@ -26,7 +26,6 @@
#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/storage/file_chunker.hpp"
-#include "src/buildtool/storage/garbage_collector.hpp"
#include "src/buildtool/storage/large_object_cas.hpp"
#include "src/buildtool/storage/local_cas.hpp"
@@ -45,8 +44,8 @@ auto LargeObjectCAS<kDoGlobalUplink, kType>::GetEntryPath(
// trees is used:
bool uplinked =
IsTreeObject(kType) and not Compatibility::IsCompatible()
- ? GarbageCollector::GlobalUplinkTree(digest)
- : GarbageCollector::GlobalUplinkLargeBlob(digest);
+ ? uplinker_.UplinkTree(digest)
+ : uplinker_.UplinkLargeBlob(digest);
if (uplinked and FileSystemManager::IsFile(file_path)) {
return file_path;
}
diff --git a/src/buildtool/storage/local_ac.hpp b/src/buildtool/storage/local_ac.hpp
index 98061e8a..c3694915 100644
--- a/src/buildtool/storage/local_ac.hpp
+++ b/src/buildtool/storage/local_ac.hpp
@@ -23,8 +23,8 @@
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/logging/logger.hpp"
#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/garbage_collector.hpp"
#include "src/buildtool/storage/local_cas.hpp"
+#include "src/buildtool/storage/uplinker.hpp"
// forward declarations
namespace build::bazel::remote::execution::v2 {
@@ -34,10 +34,10 @@ class ActionResult;
namespace bazel_re = build::bazel::remote::execution::v2;
/// \brief The action cache for storing action results.
-/// Supports global uplinking across all generations using the garbage
-/// collector. The uplink is automatically performed for every entry that is
-/// read and already exists in an older generation.
-/// \tparam kDoGlobalUplink Enable global uplinking via garbage collector.
+/// Supports global uplinking across all generations. The uplink is
+/// automatically performed for every entry that is read and already exists in
+/// an older generation.
+/// \tparam kDoGlobalUplink Enable global uplinking.
template <bool kDoGlobalUplink>
class LocalAC {
public:
@@ -45,8 +45,10 @@ class LocalAC {
using LocalGenerationAC = LocalAC</*kDoGlobalUplink=*/false>;
explicit LocalAC(gsl::not_null<LocalCAS<kDoGlobalUplink> const*> const& cas,
- GenerationConfig const& config) noexcept
- : cas_{*cas}, file_store_{config.action_cache} {};
+ GenerationConfig const& config,
+ gsl::not_null<Uplinker<kDoGlobalUplink> const*> const&
+ uplinker) noexcept
+ : cas_{*cas}, file_store_{config.action_cache}, uplinker_{*uplinker} {};
LocalAC(LocalAC const&) = default;
LocalAC(LocalAC&&) noexcept = default;
@@ -92,6 +94,7 @@ class LocalAC {
LocalCAS<kDoGlobalUplink> const& cas_;
FileStorage<ObjectType::File, kStoreMode, /*kSetEpochTime=*/false>
file_store_;
+ Uplinker<kDoGlobalUplink> const& uplinker_;
[[nodiscard]] auto ReadResult(bazel_re::Digest const& digest) const noexcept
-> std::optional<bazel_re::ActionResult>;
diff --git a/src/buildtool/storage/local_ac.tpp b/src/buildtool/storage/local_ac.tpp
index 38facf21..559346f5 100644
--- a/src/buildtool/storage/local_ac.tpp
+++ b/src/buildtool/storage/local_ac.tpp
@@ -15,6 +15,8 @@
#ifndef INCLUDED_SRC_BUILDTOOL_STORAGE_LOCAL_AC_TPP
#define INCLUDED_SRC_BUILDTOOL_STORAGE_LOCAL_AC_TPP
+#include <tuple> //std::ignore
+
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/storage/local_ac.hpp"
@@ -38,8 +40,7 @@ auto LocalAC<kDoGlobalUplink>::CachedResult(bazel_re::Digest const& action_id)
if constexpr (kDoGlobalUplink) {
// Uplink any existing action-cache entries in storage generations
- [[maybe_unused]] bool found =
- GarbageCollector::GlobalUplinkActionCacheEntry(action_id);
+ std::ignore = uplinker_.UplinkActionCacheEntry(action_id);
}
auto const entry =
diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp
index 64811a62..cbaa0439 100644
--- a/src/buildtool/storage/local_cas.hpp
+++ b/src/buildtool/storage/local_cas.hpp
@@ -24,17 +24,17 @@
#include "src/buildtool/file_system/git_repo.hpp"
#include "src/buildtool/file_system/object_cas.hpp"
#include "src/buildtool/storage/config.hpp"
-#include "src/buildtool/storage/garbage_collector.hpp"
#include "src/buildtool/storage/large_object_cas.hpp"
+#include "src/buildtool/storage/uplinker.hpp"
#include "src/utils/cpp/expected.hpp"
/// \brief The local (logical) CAS for storing blobs and trees.
/// Blobs can be stored/queried as executable or non-executable. Trees might be
/// treated differently depending on the compatibility mode. Supports global
-/// uplinking across all generations using the garbage collector. The uplink
-/// is automatically performed for every entry that is read and every entry that
-/// is stored and already exists in an older generation.
-/// \tparam kDoGlobalUplink Enable global uplinking via garbage collector.
+/// uplinking across all generations. The uplink is automatically performed for
+/// every entry that is read and every entry that is stored and already exists
+/// in an older generation.
+/// \tparam kDoGlobalUplink Enable global uplinking.
template <bool kDoGlobalUplink>
class LocalCAS {
public:
@@ -45,12 +45,15 @@ class LocalCAS {
/// Note that the base path is concatenated by a single character
/// 'f'/'x'/'t' for each internally used physical CAS.
/// \param base The base path for the CAS.
- explicit LocalCAS(GenerationConfig const& config)
- : cas_file_{config.cas_f, Uplinker<ObjectType::File>()},
- cas_exec_{config.cas_x, Uplinker<ObjectType::Executable>()},
- cas_tree_{config.cas_t, Uplinker<ObjectType::Tree>()},
- cas_file_large_{this, config},
- cas_tree_large_{this, config} {}
+ explicit LocalCAS(
+ GenerationConfig const& config,
+ gsl::not_null<Uplinker<kDoGlobalUplink> const*> const& uplinker)
+ : cas_file_{config.cas_f, MakeUplinker<ObjectType::File>(uplinker)},
+ cas_exec_{config.cas_x,
+ MakeUplinker<ObjectType::Executable>(uplinker)},
+ cas_tree_{config.cas_t, MakeUplinker<ObjectType::Tree>(uplinker)},
+ cas_file_large_{this, config, uplinker},
+ cas_tree_large_{this, config, uplinker} {}
/// \brief Obtain path to the storage root.
/// \param type Type of the storage to be obtained.
@@ -260,19 +263,19 @@ class LocalCAS {
/// \brief Provides uplink via "exists callback" for physical object CAS.
template <ObjectType kType>
- [[nodiscard]] static auto Uplinker() ->
+ [[nodiscard]] static auto MakeUplinker(
+ gsl::not_null<Uplinker<kDoGlobalUplink> const*> const& uplinker) ->
typename ObjectCAS<kType>::ExistsFunc {
if constexpr (kDoGlobalUplink) {
- return [](auto digest, auto /*path*/) {
- if (not Compatibility::IsCompatible()) {
+ return [uplinker](auto const& digest, auto const& /*path*/) {
+ if constexpr (IsTreeObject(kType)) {
// in non-compatible mode, do explicit deep tree uplink
- if constexpr (IsTreeObject(kType)) {
- return GarbageCollector::GlobalUplinkTree(digest);
+ // in compatible mode, treat all trees as blobs
+ if (not Compatibility::IsCompatible()) {
+ return uplinker->UplinkTree(digest);
}
}
- // in compatible mode, treat all trees as blobs
- return GarbageCollector::GlobalUplinkBlob(
- digest, IsExecutableObject(kType));
+ return uplinker->UplinkBlob(digest, IsExecutableObject(kType));
};
}
return ObjectCAS<kType>::kDefaultExists;
diff --git a/src/buildtool/storage/storage.hpp b/src/buildtool/storage/storage.hpp
index ae56ef91..070c8fa6 100644
--- a/src/buildtool/storage/storage.hpp
+++ b/src/buildtool/storage/storage.hpp
@@ -28,26 +28,28 @@
#include "src/buildtool/storage/local_ac.hpp"
#include "src/buildtool/storage/local_cas.hpp"
#include "src/buildtool/storage/target_cache.hpp"
+#include "src/buildtool/storage/uplinker.hpp"
/// \brief The local storage for accessing CAS and caches.
/// Maintains an instance of LocalCAS, LocalAC, TargetCache. Supports global
-/// uplinking across all generations using the garbage collector. The uplink is
-/// automatically performed by the affected storage instance (CAS, action cache,
-/// target cache).
-/// \tparam kDoGlobalUplink Enable global uplinking via garbage collector.
+/// uplinking across all generations. The uplink is automatically performed by
+/// the affected storage instance (CAS, action cache, target cache).
+/// \tparam kDoGlobalUplink Enable global uplinking.
template <bool kDoGlobalUplink>
class LocalStorage {
public:
static constexpr std::size_t kYoungest = 0U;
+ using Uplinker_t = Uplinker<kDoGlobalUplink>;
using CAS_t = LocalCAS<kDoGlobalUplink>;
using AC_t = LocalAC<kDoGlobalUplink>;
using TC_t = ::TargetCache<kDoGlobalUplink>;
explicit LocalStorage(GenerationConfig const& config)
- : cas_{std::make_shared<CAS_t>(config)},
- ac_{std::make_shared<AC_t>(&*cas_, config)},
- tc_{std::make_shared<TC_t>(&*cas_, config)} {}
+ : uplinker_{std::make_shared<Uplinker_t>(config.storage_config)},
+ cas_{std::make_shared<CAS_t>(config, &*uplinker_)},
+ ac_{std::make_shared<AC_t>(&*cas_, config, &*uplinker_)},
+ tc_{std::make_shared<TC_t>(&*cas_, config, &*uplinker_)} {}
/// \brief Get the CAS instance.
[[nodiscard]] auto CAS() const noexcept -> CAS_t const& { return *cas_; }
@@ -63,13 +65,14 @@ class LocalStorage {
}
private:
+ std::shared_ptr<Uplinker_t const> uplinker_;
std::shared_ptr<CAS_t const> cas_;
std::shared_ptr<AC_t const> ac_;
std::shared_ptr<TC_t const> tc_;
};
#ifdef BOOTSTRAP_BUILD_TOOL
-// disable global uplinking (via garbage collector) for global storage singleton
+// disable global uplinking
constexpr auto kDefaultDoGlobalUplink = false;
#else
constexpr auto kDefaultDoGlobalUplink = true;
@@ -90,22 +93,9 @@ class Storage : public LocalStorage<kDefaultDoGlobalUplink> {
return GetStorage();
}
- /// \brief Get specific storage generation.
- /// Number of generations is read from \ref
- /// StorageConfig::Instance().NumGenerations().
- /// \param index the generation index (0 is latest).
- /// \returns The specific storage generation.
- [[nodiscard]] static auto Generation(std::size_t index) noexcept
- -> ::Generation const& {
- return GetGenerations()[index];
- }
-
/// \brief Reinitialize storage instance and generations.
/// Use if global \ref StorageConfig was changed. Not thread-safe!
- static void Reinitialize() noexcept {
- GetStorage() = CreateStorage();
- GetGenerations() = CreateGenerations();
- }
+ static void Reinitialize() noexcept { GetStorage() = CreateStorage(); }
private:
using LocalStorage<kDefaultDoGlobalUplink>::LocalStorage;
@@ -116,29 +106,10 @@ class Storage : public LocalStorage<kDefaultDoGlobalUplink> {
return Storage{gen_config};
}
- [[nodiscard]] static auto CreateGenerations() noexcept
- -> std::vector<::Generation> {
- auto count = StorageConfig::Instance().NumGenerations();
- std::vector<::Generation> generations{};
- generations.reserve(count);
- for (std::size_t i = 0; i < count; ++i) {
- auto gen_config =
- StorageConfig::Instance().CreateGenerationConfig(i);
- generations.emplace_back(gen_config);
- }
- return generations;
- }
-
[[nodiscard]] static auto GetStorage() noexcept -> Storage& {
static auto instance = CreateStorage();
return instance;
}
-
- [[nodiscard]] static auto GetGenerations() noexcept
- -> std::vector<::Generation>& {
- static auto generations = CreateGenerations();
- return generations;
- }
};
#endif // INCLUDED_SRC_BUILDTOOL_STORAGE_STORAGE_HPP
diff --git a/src/buildtool/storage/target_cache.hpp b/src/buildtool/storage/target_cache.hpp
index 787a26b3..e5a64737 100644
--- a/src/buildtool/storage/target_cache.hpp
+++ b/src/buildtool/storage/target_cache.hpp
@@ -35,13 +35,14 @@
#include "src/buildtool/storage/local_cas.hpp"
#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 using the garbage
-/// collector. The uplink is automatically performed for every entry that is
-/// read and already exists in an older generation.
-/// \tparam kDoGlobalUplink Enable global uplinking via garbage collector.
+/// Supports global uplinking across all generations. The uplink is
+/// automatically performed for every entry that is read and already exists in
+/// an older generation.
+/// \tparam kDoGlobalUplink Enable global uplinking.
template <bool kDoGlobalUplink>
class TargetCache {
public:
@@ -54,9 +55,11 @@ class TargetCache {
explicit TargetCache(
gsl::not_null<LocalCAS<kDoGlobalUplink> const*> const& cas,
- GenerationConfig const& config)
+ GenerationConfig const& config,
+ gsl::not_null<Uplinker<kDoGlobalUplink> const*> const& uplinker)
: cas_{*cas},
file_store_{config.target_cache / ComputeShard()},
+ uplinker_{*uplinker},
explicit_shard_{std::nullopt} {
if constexpr (kDoGlobalUplink) {
// write backend description (shard) to CAS
@@ -133,6 +136,7 @@ class TargetCache {
kStoreMode,
/*kSetEpochTime=*/false>
file_store_;
+ Uplinker<kDoGlobalUplink> const& uplinker_;
std::optional<std::string> explicit_shard_{std::nullopt};
explicit TargetCache(TargetCache const& other,
@@ -140,6 +144,7 @@ class TargetCache {
: cas_{other.cas_},
file_store_{other.file_store_.StorageRoot().parent_path() /
explicit_shard},
+ uplinker_{other.uplinker_},
explicit_shard_{explicit_shard} {}
template <bool kIsLocalGeneration = not kDoGlobalUplink>
diff --git a/src/buildtool/storage/target_cache.tpp b/src/buildtool/storage/target_cache.tpp
index c2e89134..9ddd19d2 100644
--- a/src/buildtool/storage/target_cache.tpp
+++ b/src/buildtool/storage/target_cache.tpp
@@ -16,10 +16,10 @@
#define INCLUDED_SRC_BUILDTOOL_STORAGE_TARGET_CACHE_TPP
#include <exception>
+#include <tuple> //std::ignore
#include "nlohmann/json.hpp"
#include "src/buildtool/logging/log_level.hpp"
-#include "src/buildtool/storage/garbage_collector.hpp"
#include "src/buildtool/storage/target_cache.hpp"
template <bool kDoGlobalUplink>
@@ -78,9 +78,7 @@ auto TargetCache<kDoGlobalUplink>::Read(
if constexpr (kDoGlobalUplink) {
// Uplink any existing target cache entry in storage generations
- [[maybe_unused]] auto found =
- GarbageCollector::GlobalUplinkTargetCacheEntry(key,
- explicit_shard_);
+ std::ignore = uplinker_.UplinkTargetCacheEntry(key, explicit_shard_);
}
auto const entry =