Core execution logic shared by `codspeed exec` and `codspeed run` with config targets. Sets up the orchestrator and drives execution. Exec-harness installation is handled by the orchestrator when exec targets are present.
(
mut config: OrchestratorConfig,
api_client: &mut CodSpeedAPIClient,
setup_cache_dir: Option<&Path>,
)
| 120 | /// Sets up the orchestrator and drives execution. Exec-harness installation is handled |
| 121 | /// by the orchestrator when exec targets are present. |
| 122 | pub async fn execute_config( |
| 123 | mut config: OrchestratorConfig, |
| 124 | api_client: &mut CodSpeedAPIClient, |
| 125 | setup_cache_dir: Option<&Path>, |
| 126 | ) -> Result<()> { |
| 127 | // Resolve exec target binary paths so memtrack can discover statically linked |
| 128 | // allocators (which may not live in known build dirs). |
| 129 | let memtrack_binaries: HashSet<_> = config |
| 130 | .targets |
| 131 | .iter() |
| 132 | .filter_map(|t| match t { |
| 133 | executor::BenchmarkTarget::Exec { command, .. } => command.first().cloned(), |
| 134 | _ => None, |
| 135 | }) |
| 136 | .filter_map(|bin| { |
| 137 | let result = match &config.working_directory { |
| 138 | Some(cwd) => which::which_in(&bin, std::env::var_os("PATH"), cwd), |
| 139 | None => which::which(&bin), |
| 140 | }; |
| 141 | result.ok() |
| 142 | }) |
| 143 | .collect(); |
| 144 | |
| 145 | if !memtrack_binaries.is_empty() { |
| 146 | let mut all_paths = memtrack_binaries; |
| 147 | |
| 148 | // Merge with any user-provided value from the parent environment. |
| 149 | if let Some(existing) = std::env::var_os("CODSPEED_MEMTRACK_BINARIES") { |
| 150 | all_paths.extend(std::env::split_paths(&existing)); |
| 151 | } |
| 152 | |
| 153 | let joined = |
| 154 | std::env::join_paths(&all_paths).expect("memtrack binary paths should be joinable"); |
| 155 | config.extra_env.insert( |
| 156 | "CODSPEED_MEMTRACK_BINARIES".into(), |
| 157 | joined.to_string_lossy().into_owned(), |
| 158 | ); |
| 159 | } |
| 160 | |
| 161 | let orchestrator = executor::Orchestrator::new(config, api_client).await?; |
| 162 | |
| 163 | if !orchestrator.is_local() { |
| 164 | super::show_banner(); |
| 165 | } |
| 166 | |
| 167 | debug!("config: {:#?}", orchestrator.config); |
| 168 | |
| 169 | orchestrator.execute(setup_cache_dir, api_client).await?; |
| 170 | |
| 171 | Ok(()) |
| 172 | } |