From 9ff01a766d98359c7dcf199aa6c4fba7fb427140 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 7 May 2025 10:22:39 +0200 Subject: profile: include remote-execution properties Include in the profile also the effective remote-execution endpoint, properties, and dispatch list. Software projects are often tested in a variety of environments or hardware configurations; as, obviously, the performance might differ significantly (especially depending on the used hardware) a proper analysis therefore requires the possibility to distinguish the various backends. Adding the effective configuration adds this posibility. --- doc/concepts/profiling.md | 7 +++++++ share/man/just-profile.5.md | 13 +++++++++++++ src/buildtool/main/main.cpp | 3 +++ src/buildtool/profile/TARGETS | 2 ++ src/buildtool/profile/profile.cpp | 18 ++++++++++++++++++ src/buildtool/profile/profile.hpp | 2 ++ 6 files changed, 45 insertions(+) diff --git a/doc/concepts/profiling.md b/doc/concepts/profiling.md index f63bc91f..4030b638 100644 --- a/doc/concepts/profiling.md +++ b/doc/concepts/profiling.md @@ -109,6 +109,13 @@ more keys possibly added in the future). is a value derived not only from the command line but also from the context of a file (given via `-c`) possibly local on the machine `just` was run. + - The key `"remote"` describes the remote-exeuction endpoint, + including the used properties and dispatch list. This allow + distinguishing builds in different environments (possibly using + different hardware); this can be relevant both for performance + as well as failure statistics for tests. Again, the reason for + including it in the profile is that local files are read (for + the dispatch list). - The key `"actions"` contains a JSON object with the keys being precisely the key identifiers of the actions attempted to run. The action identifiers are the same as in the `--dump-graph` or diff --git a/share/man/just-profile.5.md b/share/man/just-profile.5.md index 991472cb..b8efb16c 100644 --- a/share/man/just-profile.5.md +++ b/share/man/just-profile.5.md @@ -45,6 +45,19 @@ The profile file contains the following information. - For the key *`"configuration"`* the build configuration in which the target was analysed/built/installed. +- For the key *`"remote"`* an object describing the remote-execution + configuration. The following keys are used. + + - If a remote-execution endpoint is used, for the key *`"address"`*, + a string of the form `address:port` is given. + + - For the key *`"properties"`* the remote-execution properties are + specified (naturally as an object). + + - For the key *`"dispatch"`* the dispatch list is given as an array + of pairs (arrays of length two) of a property map and an enpoint + as `address:port` string. + - For the key *`"exit code"`* the exit code of the **`just`**(1) process. - For the key *`"analysis errors"`*, if present, a list of error messages diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 896d0545..c071b27c 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -941,6 +941,9 @@ auto main(int argc, char* argv[]) -> int { } return kExitBuildEnvironment; } + if (profile != nullptr) { + profile->SetRemoteExecutionConfig(*remote_exec_config); + } // Set up storage for client-side operation. This needs to have all the // correct remote endpoint info in order to instantiate the diff --git a/src/buildtool/profile/TARGETS b/src/buildtool/profile/TARGETS index 318ed075..713e2c89 100644 --- a/src/buildtool/profile/TARGETS +++ b/src/buildtool/profile/TARGETS @@ -6,12 +6,14 @@ , "deps": [ ["@", "json", "", "json"] , ["src/buildtool/execution_api/common", "common"] + , ["src/buildtool/execution_api/remote", "config"] , ["src/buildtool/main", "cli"] ] , "private-deps": [ ["@", "gsl", "", "gsl"] , ["src/buildtool/common", "cli"] , ["src/buildtool/common", "common"] + , ["src/buildtool/common/remote", "remote_common"] , ["src/utils/cpp", "expected"] ] , "stage": ["src", "buildtool", "profile"] diff --git a/src/buildtool/profile/profile.cpp b/src/buildtool/profile/profile.cpp index f37629f1..1407ddbd 100644 --- a/src/buildtool/profile/profile.cpp +++ b/src/buildtool/profile/profile.cpp @@ -20,6 +20,7 @@ #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/cli.hpp" +#include "src/buildtool/common/remote/remote_common.hpp" #include "src/utils/cpp/expected.hpp" void Profile::Write(int exit_code) { @@ -156,3 +157,20 @@ void Profile::NoteAnalysisError(std::string const& error_message) { std::unique_lock lock{mutex_}; analysis_errors_.emplace_back(error_message); } + +void Profile::SetRemoteExecutionConfig(RemoteExecutionConfig const& config) { + auto remote = nlohmann::json::object(); + if (config.remote_address) { + remote["address"] = config.remote_address->ToJson(); + } + remote["properties"] = config.platform_properties; + auto dispatch = nlohmann::json::array(); + for (auto const& dispatch_entry : config.dispatch) { + auto entry = nlohmann::json::array(); + entry.emplace_back(dispatch_entry.first); + entry.emplace_back(dispatch_entry.second.ToJson()); + dispatch.emplace_back(entry); + } + remote["dispatch"] = dispatch; + profile_["remote"] = remote; +} diff --git a/src/buildtool/profile/profile.hpp b/src/buildtool/profile/profile.hpp index d172ae85..a16d9996 100644 --- a/src/buildtool/profile/profile.hpp +++ b/src/buildtool/profile/profile.hpp @@ -25,6 +25,7 @@ #include "nlohmann/json.hpp" #include "src/buildtool/execution_api/common/execution_response.hpp" +#include "src/buildtool/execution_api/remote/config.hpp" #include "src/buildtool/main/cli.hpp" class Profile { @@ -36,6 +37,7 @@ class Profile { } void Write(int exit_code); + void SetRemoteExecutionConfig(RemoteExecutionConfig const&); void SetTarget(nlohmann::json target); void SetConfiguration(nlohmann::json configuration); void NoteActionCompleted(std::string const& id, -- cgit v1.2.3