summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp2
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp8
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp35
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp64
4 files changed, 91 insertions, 18 deletions
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index 331aaaa5..3a2beb64 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -45,7 +45,7 @@ auto LocalAction::Execute(Logger const* logger) noexcept
"start execution\n"
" - exec_dir digest: {}\n"
" - action digest: {}",
- root_digest_.hash(),
+ static_cast<bazel_re::Digest>(root_digest_).hash(),
action.hash());
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index c2893917..766549bc 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -166,6 +166,14 @@ auto BazelApi::CreateAction(
Logger::Log(LogLevel::Debug, "failed to create digest for tree.");
return std::nullopt;
}
+
+ Logger::Log(LogLevel::Trace, [&digest]() {
+ std::ostringstream oss{};
+ oss << "upload root directory" << std::endl;
+ oss << fmt::format(" - root digest: {}", digest->hash()) << std::endl;
+ return oss.str();
+ });
+
if (not Upload(blobs, /*skip_find_missing=*/false)) {
Logger::Log(LogLevel::Debug, "failed to upload blobs for tree.");
return std::nullopt;
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
index da8b518c..20743c3e 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_cas_client.cpp
@@ -131,6 +131,13 @@ auto BazelCasClient::GetTree(std::string const& instance_name,
auto BazelCasClient::UpdateSingleBlob(std::string const& instance_name,
BazelBlob const& blob) noexcept -> bool {
+ logger_.Emit(LogLevel::Trace, [&blob]() {
+ std::ostringstream oss{};
+ oss << "upload single blob" << std::endl;
+ oss << fmt::format(" - {}", blob.digest.hash()) << std::endl;
+ return oss.str();
+ });
+
thread_local static std::string uuid{};
if (uuid.empty()) {
auto id = CreateProcessUniqueId();
@@ -185,6 +192,20 @@ auto BazelCasClient::FindMissingBlobs(std::string const& instance_name,
LogStatus(&logger_, LogLevel::Debug, status);
}
+ logger_.Emit(LogLevel::Trace, [&start, &end, &result]() {
+ std::ostringstream oss{};
+ oss << "find missing blobs" << std::endl;
+ std::for_each(start, end, [&oss](auto const& digest) {
+ oss << fmt::format(" - {}", digest.hash()) << std::endl;
+ });
+ oss << "missing blobs" << std::endl;
+ std::for_each(
+ result.cbegin(), result.cend(), [&oss](auto const& digest) {
+ oss << fmt::format(" - {}", digest.hash()) << std::endl;
+ });
+ return oss.str();
+ });
+
return result;
}
@@ -225,6 +246,20 @@ auto BazelCasClient::DoBatchUpdateBlobs(std::string const& instance_name,
}
}
+ logger_.Emit(LogLevel::Trace, [&start, &end, &result]() {
+ std::ostringstream oss{};
+ oss << "upload blobs" << std::endl;
+ std::for_each(start, end, [&oss](auto const& blob) {
+ oss << fmt::format(" - {}", blob.digest.hash()) << std::endl;
+ });
+ oss << "received blobs" << std::endl;
+ std::for_each(
+ result.cbegin(), result.cend(), [&oss](auto const& digest) {
+ oss << fmt::format(" - {}", digest.hash()) << std::endl;
+ });
+ return oss.str();
+ });
+
return result;
}
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 10f578cf..02a56f49 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -37,6 +37,23 @@ class ExecutorImpl {
IExecutionAction::CacheFlag cache_flag)
-> std::optional<IExecutionResponse::Ptr> {
auto const& inputs = action->Dependencies();
+ auto const tree_action = action->Content().IsTreeAction();
+
+ logger.Emit(LogLevel::Trace, [&inputs, tree_action]() {
+ std::ostringstream oss{};
+ oss << "execute " << (tree_action ? "tree " : "") << "action"
+ << std::endl;
+ for (auto const& [local_path, artifact] : inputs) {
+ auto const& info = artifact->Content().Info();
+ oss << fmt::format(
+ " - needs {} {}",
+ local_path,
+ info ? info->ToString() : std::string{"[???]"})
+ << std::endl;
+ }
+ return oss.str();
+ });
+
auto const root_digest = CreateRootDigest(api, inputs);
if (not root_digest) {
Logger::Log(LogLevel::Error,
@@ -44,7 +61,7 @@ class ExecutorImpl {
return nullptr;
}
- if (action->Content().IsTreeAction()) {
+ if (tree_action) {
auto const& tree_artifact = action->OutputDirs()[0].node->Content();
bool failed_inputs = false;
for (auto const& [local_path, artifact] : inputs) {
@@ -58,20 +75,6 @@ class ExecutorImpl {
Progress::Instance().Start(action->Content().Id());
Statistics::Instance().IncrementActionsQueuedCounter();
- logger.Emit(LogLevel::Trace, [&inputs]() {
- std::ostringstream oss{};
- oss << "start processing" << std::endl;
- for (auto const& [local_path, artifact] : inputs) {
- auto const& info = artifact->Content().Info();
- oss << fmt::format(
- " - needs {} {}",
- local_path,
- info ? info->ToString() : std::string{"[???]"})
- << std::endl;
- }
- return oss.str();
- });
-
auto remote_action = api->CreateAction(*root_digest,
action->Command(),
action->OutputFilePaths(),
@@ -99,6 +102,7 @@ class ExecutorImpl {
/// \returns True if artifact is available at the point of return, false
/// otherwise
[[nodiscard]] static auto VerifyOrUploadArtifact(
+ Logger const& logger,
gsl::not_null<DependencyGraph::ArtifactNode const*> const& artifact,
gsl::not_null<IExecutionApi*> const& api) noexcept -> bool {
auto const object_info_opt = artifact->Content().Info();
@@ -115,6 +119,13 @@ class ExecutorImpl {
// If the artifact has digest, we check that an object with this digest
// is available to the execution API
if (object_info_opt) {
+ logger.Emit(LogLevel::Trace, [&object_info_opt]() {
+ std::ostringstream oss{};
+ oss << fmt::format("upload KNOWN artifact: {}",
+ object_info_opt->ToString())
+ << std::endl;
+ return oss.str();
+ });
if (not api->IsAvailable(object_info_opt->digest) and
not VerifyOrUploadKnownArtifact(
api,
@@ -134,6 +145,13 @@ class ExecutorImpl {
// Note that we can be sure now that file_path_opt has a value and
// that the path stored is relative to the workspace dir, so we need to
// prepend it
+ logger.Emit(LogLevel::Trace, [&file_path_opt]() {
+ std::ostringstream oss{};
+ oss << fmt::format("upload LOCAL artifact: {}",
+ file_path_opt->string())
+ << std::endl;
+ return oss.str();
+ });
auto repo = artifact->Content().Repository();
auto new_info = UploadFile(api, repo, *file_path_opt);
if (not new_info) {
@@ -176,6 +194,16 @@ class ExecutorImpl {
}
}
+ Logger::Log(LogLevel::Trace, [&tree]() {
+ std::ostringstream oss{};
+ oss << "upload directory content" << std::endl;
+ for (auto const& [path, entry] : *tree) {
+ oss << fmt::format(" - {}: {}", path, entry->Hash())
+ << std::endl;
+ }
+ return oss.str();
+ });
+
// find missing digests
auto missing_digests = api->IsAvailable(digests);
@@ -532,7 +560,8 @@ class Executor {
[[nodiscard]] auto Process(
gsl::not_null<DependencyGraph::ArtifactNode const*> const& artifact)
const noexcept -> bool {
- return Impl::VerifyOrUploadArtifact(artifact, api_);
+ Logger logger("artifact:" + ToHexString(artifact->Content().Id()));
+ return Impl::VerifyOrUploadArtifact(logger, artifact, api_);
}
private:
@@ -595,7 +624,8 @@ class Rebuilder {
[[nodiscard]] auto Process(
gsl::not_null<DependencyGraph::ArtifactNode const*> const& artifact)
const noexcept -> bool {
- return Impl::VerifyOrUploadArtifact(artifact, api_);
+ Logger logger("artifact:" + ToHexString(artifact->Content().Id()));
+ return Impl::VerifyOrUploadArtifact(logger, artifact, api_);
}
[[nodiscard]] auto DumpFlakyActions() const noexcept -> nlohmann::json {