summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/just-serve-config.5.md12
-rw-r--r--src/buildtool/main/main.cpp11
-rw-r--r--src/buildtool/main/serve.cpp21
-rw-r--r--src/buildtool/serve_api/remote/TARGETS5
-rw-r--r--src/buildtool/serve_api/remote/config.hpp14
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp3
6 files changed, 61 insertions, 5 deletions
diff --git a/share/man/just-serve-config.5.md b/share/man/just-serve-config.5.md
index 4bd51420..f01536eb 100644
--- a/share/man/just-serve-config.5.md
+++ b/share/man/just-serve-config.5.md
@@ -81,7 +81,17 @@ The configuration file is given by a JSON object.
is used.
For subkey *`"action timeout"`* the value in a number specifying the timeout
limit in seconds for actions run during a remote build. If unset, the default
- value 300 is used.
+ value 300 is used.
+ For subkey *`"target-cache write strategy"`* the value has to
+ be one of the values *`"disable"`*, *`"sync"`*, or *`"split"`*.
+ The default is *`"sync"`*, giving the instruction to
+ synchronize artifacts and write target-level cache entries.
+ The value *`"split"`* does the same using blob splitting
+ when synchronizing artifacts, provided it is supported by the
+ remote-execution endpoint. The value *`"disable"`* disables
+ adding new entries to the target-level cache, which defeats the
+ purpose of typical set up to share target-level computations
+ between clients.
See also
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index ba5eb620..65daa0d8 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -136,7 +136,8 @@ void SetupExecutionConfig(EndpointArguments const& eargs,
void SetupServeConfig(ServeArguments const& srvargs,
CommonArguments const& cargs,
- BuildArguments const& bargs) {
+ BuildArguments const& bargs,
+ TCArguments const& tc) {
if (srvargs.remote_serve_address) {
if (not RemoteServeConfig::SetRemoteAddress(
*srvargs.remote_serve_address)) {
@@ -181,6 +182,11 @@ void SetupServeConfig(ServeArguments const& srvargs,
Logger::Log(LogLevel::Error, "Setting action timeout failed.");
std::exit(kExitFailure);
}
+ RemoteServeConfig::SetTCStrategy(tc.target_cache_write_strategy);
+ if (tc.target_cache_write_strategy == TargetCacheWriteStrategy::Disable) {
+ Logger::Log(LogLevel::Info,
+ "Target-level cache writing of serve service is disabled.");
+ }
}
void SetupAuthConfig(CommonAuthArguments const& authargs,
@@ -830,7 +836,8 @@ auto main(int argc, char* argv[]) -> int {
SetupHashFunction();
SetupExecutionConfig(
arguments.endpoint, arguments.build, arguments.rebuild);
- SetupServeConfig(arguments.serve, arguments.common, arguments.build);
+ SetupServeConfig(
+ arguments.serve, arguments.common, arguments.build, arguments.tc);
SetupAuthConfig(arguments.auth, arguments.cauth, arguments.sauth);
if (arguments.cmd == SubCommand::kGc) {
diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp
index 1c079032..32da7801 100644
--- a/src/buildtool/main/serve.cpp
+++ b/src/buildtool/main/serve.cpp
@@ -399,6 +399,27 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
clargs->build.timeout =
std::size_t(timeout->Number()) * std::chrono::seconds{1};
}
+ auto strategy = build_args->Get("target-cache write strategy",
+ Expression::none_t{});
+ if (strategy.IsNotNull()) {
+ if (not strategy->IsString()) {
+ Logger::Log(
+ LogLevel::Error,
+ "just serve: configuration-file provided target-cache "
+ "write strategy has to be a string, but found {}",
+ strategy->ToString());
+ std::exit(kExitFailure);
+ }
+ auto s_value = ToTargetCacheWriteStrategy(strategy->String());
+ if (not s_value) {
+ Logger::Log(LogLevel::Error,
+ "just serve: configuration-file provided unknown "
+ "target-cache write strategy {}",
+ strategy->ToString());
+ std::exit(kExitFailure);
+ }
+ clargs->tc.target_cache_write_strategy = *s_value;
+ }
}
}
diff --git a/src/buildtool/serve_api/remote/TARGETS b/src/buildtool/serve_api/remote/TARGETS
index f77fac04..8b64aee7 100644
--- a/src/buildtool/serve_api/remote/TARGETS
+++ b/src/buildtool/serve_api/remote/TARGETS
@@ -2,7 +2,10 @@
{ "type": ["@", "rules", "CC", "library"]
, "name": ["config"]
, "hdrs": ["config.hpp"]
- , "deps": [["src/buildtool/common/remote", "remote_common"]]
+ , "deps":
+ [ ["src/buildtool/common/remote", "remote_common"]
+ , ["src/buildtool/main", "build_utils"]
+ ]
, "stage": ["src", "buildtool", "serve_api", "remote"]
}
, "source_tree_client":
diff --git a/src/buildtool/serve_api/remote/config.hpp b/src/buildtool/serve_api/remote/config.hpp
index 94f00f8e..8978565b 100644
--- a/src/buildtool/serve_api/remote/config.hpp
+++ b/src/buildtool/serve_api/remote/config.hpp
@@ -21,6 +21,7 @@
#include <vector>
#include "src/buildtool/common/remote/remote_common.hpp"
+#include "src/buildtool/main/build_utils.hpp"
class RemoteServeConfig {
public:
@@ -65,6 +66,10 @@ class RemoteServeConfig {
return Instance().timeout_ > std::chrono::seconds{0};
}
+ static void SetTCStrategy(TargetCacheWriteStrategy strategy) noexcept {
+ Instance().tc_strategy_ = strategy;
+ }
+
// Remote execution address, if set
[[nodiscard]] static auto RemoteAddress() noexcept
-> std::optional<ServerAddress> {
@@ -93,6 +98,12 @@ class RemoteServeConfig {
return Instance().timeout_;
}
+ // Get the target-level cache write strategy
+ [[nodiscard]] static auto TCStrategy() noexcept
+ -> TargetCacheWriteStrategy {
+ return Instance().tc_strategy_;
+ }
+
private:
// Server address of remote execution.
std::optional<ServerAddress> remote_address_{};
@@ -108,6 +119,9 @@ class RemoteServeConfig {
// Action timeout
std::chrono::milliseconds timeout_{};
+
+ // Strategy for synchronizing target-level cache
+ TargetCacheWriteStrategy tc_strategy_{TargetCacheWriteStrategy::Sync};
};
#endif // INCLUDED_SRC_BUILDTOOL_SERVE_API_REMOTE_CONFIG_HPP
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index 8e097397..f36d60a9 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -541,7 +541,8 @@ auto TargetService::ServeTarget(
build_result->extra_infos,
jobs,
traverser.GetLocalApi(),
- traverser.GetRemoteApi());
+ traverser.GetRemoteApi(),
+ RemoteServeConfig::TCStrategy());
if (build_result->failed_artifacts) {
auto msg =