summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/buildtool/storage/local_ac.hpp5
-rw-r--r--src/buildtool/storage/local_ac.tpp24
3 files changed, 22 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c120f104..6cb40fbd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -57,6 +57,9 @@ A feature release on top of `1.3.0`, backwards compatible.
- The size of large object entries has been reduced. The cache and
CAS must be cleaned up since stable versions before `1.4.0` cannot use
the new format.
+- The way of storing intermediate keys of the action cache has been changed.
+ The cache must be cleaned up since stable versions before `1.4.0` cannot
+ use the new format.
- Various improvements to the tests: dispatching of the summary
action is now possible, tests are independent of a .just-mrrc
file the user might have in their home directory
diff --git a/src/buildtool/storage/local_ac.hpp b/src/buildtool/storage/local_ac.hpp
index cb4aa171..a93130a5 100644
--- a/src/buildtool/storage/local_ac.hpp
+++ b/src/buildtool/storage/local_ac.hpp
@@ -20,6 +20,7 @@
#include <string>
#include "gsl/gsl"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/file_system/file_storage.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/object_type.hpp"
@@ -104,8 +105,8 @@ class LocalAC {
/// \param cas_key The key pointing at an ActionResult in the LocalCAS.
/// \return True if an entry was successfully added to the storage.
[[nodiscard]] auto WriteActionKey(
- bazel_re::Digest const& action_id,
- bazel_re::Digest const& cas_key) const noexcept -> bool;
+ ArtifactDigest const& action_id,
+ ArtifactDigest const& cas_key) const noexcept -> bool;
/// \brief Get the key pointing at an ActionResult in the LocalCAS.
/// \param action_id The id of the action that produced the result.
diff --git a/src/buildtool/storage/local_ac.tpp b/src/buildtool/storage/local_ac.tpp
index 835027ac..5fee10ff 100644
--- a/src/buildtool/storage/local_ac.tpp
+++ b/src/buildtool/storage/local_ac.tpp
@@ -19,6 +19,7 @@
#include <utility> // std::move
#include "fmt/core.h"
+#include "nlohmann/json.hpp"
#include "src/buildtool/common/bazel_types.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/storage/local_ac.hpp"
@@ -28,7 +29,9 @@ auto LocalAC<kDoGlobalUplink>::StoreResult(
bazel_re::Digest const& action_id,
bazel_re::ActionResult const& result) const noexcept -> bool {
auto const cas_key = WriteAction(result);
- return cas_key.has_value() and WriteActionKey(action_id, *cas_key);
+ return cas_key.has_value() and
+ WriteActionKey(static_cast<ArtifactDigest>(action_id),
+ static_cast<ArtifactDigest>(*cas_key));
}
template <bool kDoGlobalUplink>
@@ -117,10 +120,10 @@ requires(kIsLocalGeneration) auto LocalAC<kDoGlobalUplink>::LocalUplinkEntry(
template <bool kDoGlobalUplink>
auto LocalAC<kDoGlobalUplink>::WriteActionKey(
- bazel_re::Digest const& action_id,
- bazel_re::Digest const& cas_key) const noexcept -> bool {
- return file_store_.AddFromBytes(NativeSupport::Unprefix(action_id.hash()),
- cas_key.SerializeAsString());
+ ArtifactDigest const& action_id,
+ ArtifactDigest const& cas_key) const noexcept -> bool {
+ nlohmann::json const content = {cas_key.hash(), cas_key.size()};
+ return file_store_.AddFromBytes(action_id.hash(), content.dump());
}
template <bool kDoGlobalUplink>
@@ -141,13 +144,18 @@ auto LocalAC<kDoGlobalUplink>::ReadActionKey(bazel_re::Digest const& action_id)
fmt::format("Cache miss, entry not found {}", key_path.string())};
}
- bazel_re::Digest action_key{};
- if (not action_key.ParseFromString(*key_content)) {
+ std::optional<bazel_re::Digest> action_key;
+ try {
+ nlohmann::json j = nlohmann::json::parse(*key_content);
+ action_key = ArtifactDigest{j[0].template get<std::string>(),
+ j[1].template get<std::size_t>(),
+ /*is_tree=*/false};
+ } catch (...) {
return unexpected{
fmt::format("Parsing cache entry failed for action {}",
NativeSupport::Unprefix(action_id.hash()))};
}
- return std::move(action_key);
+ return *std::move(action_key);
}
template <bool kDoGlobalUplink>