MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / run

Method run

src/executor/memory/executor.rs:171–229  ·  view source on GitHub ↗
(
        &mut self,
        execution_context: &ExecutionContext,
        _mongo_tracer: &Option<MongoTracer>,
    )

Source from the content-addressed store, hash-verified

169 }
170
171 async fn run(
172 &mut self,
173 execution_context: &ExecutionContext,
174 _mongo_tracer: &Option<MongoTracer>,
175 ) -> Result<()> {
176 let _tunables = MemoryTunables::apply();
177
178 // Create the results/ directory inside the profile folder to avoid having memtrack create it with wrong permissions
179 let results_folder = execution_context.profile_folder.join("results");
180 std::fs::create_dir_all(&results_folder)?;
181
182 Self::ensure_privileges()?;
183
184 let (ipc, cmd_builder, _env_file) = Self::build_memtrack_command(execution_context)?;
185 let cmd = cmd_builder.build();
186 debug!("cmd: {cmd:?}");
187
188 let runner_fifo = RunnerFifo::new()?;
189 let fifo_data = Rc::new(RefCell::new(None));
190 let on_process_started = {
191 let fifo_data_cell = fifo_data.clone();
192 |mut child: tokio::process::Child| async move {
193 let (marker_result, data, exit_status) =
194 Self::handle_fifo(runner_fifo, ipc, &mut child).await?;
195 *fifo_data_cell.borrow_mut() = Some(data);
196 marker_result.save_to(&results_folder).unwrap();
197
198 Ok(exit_status)
199 }
200 };
201
202 let status = run_command_with_log_pipe_and_callback(cmd.into(), on_process_started).await?;
203 debug!("cmd exit status: {status:?}");
204
205 if !status.success() {
206 bail!("failed to execute memory tracker process: {status}");
207 }
208
209 let data = fifo_data.borrow_mut().take();
210 if let Some(data) = data
211 && let Some(integration) = data.integration
212 {
213 let results_folder = execution_context.profile_folder.join("results");
214 if let Err(e) = save_module_artifacts(
215 &execution_context.profile_folder,
216 &results_folder,
217 integration,
218 &data.bench_pids,
219 )
220 .await
221 {
222 // The memory results are complete without them; only offline
223 // stack attribution is lost.
224 error!("Failed to save memtrack module artifacts: {e:#}");
225 }
226 }
227
228 Ok(())

Callers 2

runFunction · 0.45
run_executorFunction · 0.45

Calls 5

applyFunction · 0.85
save_module_artifactsFunction · 0.85
buildMethod · 0.45
save_toMethod · 0.45

Tested by

no test coverage detected