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

Method handle_fifo

src/executor/memory/executor.rs:261–345  ·  view source on GitHub ↗
(
        mut runner_fifo: RunnerFifo,
        ipc: MemtrackIpcServer,
        child: &mut tokio::process::Child,
    )

Source from the content-addressed store, hash-verified

259
260impl MemoryExecutor {
261 async fn handle_fifo(
262 mut runner_fifo: RunnerFifo,
263 ipc: MemtrackIpcServer,
264 child: &mut tokio::process::Child,
265 ) -> anyhow::Result<(
266 ExecutionTimestamps,
267 crate::executor::shared::fifo::FifoBenchmarkData,
268 std::process::ExitStatus,
269 )> {
270 // Accept the IPC connection from memtrack and get the sender it sends us
271 // Use a timeout to prevent hanging if the process doesn't start properly
272 // https://github.com/servo/ipc-channel/issues/261
273 let (_, memtrack_sender) = timeout(Duration::from_secs(5), async move {
274 tokio::task::spawn_blocking(move || ipc.accept())
275 .await
276 .context("Failed to spawn blocking task")?
277 .context("Failed to accept IPC connection")
278 })
279 .await
280 .context("Timeout waiting for IPC connection from memtrack process")??;
281 let ipc_client = Rc::new(MemtrackIpcClient::from_accepted(memtrack_sender));
282
283 let on_cmd = async move |cmd: &FifoCommand| {
284 const INVALID_INTEGRATION_ERROR: &str = "This integration doesn't support memory profiling. Please update your integration to a version that supports memory profiling.";
285
286 match cmd {
287 FifoCommand::SetIntegration { name, version } => {
288 let min_version = match name.as_str() {
289 "codspeed-rust" => Version::new(4, 2, 0),
290 "codspeed-cpp" => Version::new(2, 1, 0),
291 "pytest-codspeed" => Version::new(4, 3, 0),
292 "codspeed-node" => Version::new(5, 2, 0),
293 "exec-harness" => Version::new(1, 0, 0),
294 _ => {
295 panic!("{INVALID_INTEGRATION_ERROR}")
296 }
297 };
298
299 let Ok(cur_version) = Version::parse(version) else {
300 panic!("Received invalid integration version");
301 };
302
303 if cur_version < min_version {
304 panic!("{INVALID_INTEGRATION_ERROR}")
305 }
306 }
307 FifoCommand::SetVersion(protocol_version) => {
308 if *protocol_version < 2 {
309 bail!(
310 "Memory profiling requires protocol version 2 or higher, but the integration is using version {protocol_version}. \
311 {INVALID_INTEGRATION_ERROR}",
312 );
313 }
314 }
315 FifoCommand::StartProfiler => {
316 debug!("Enabling memtrack via IPC");
317 if let Err(e) = ipc_client.enable() {
318 error!("Failed to enable memtrack: {e}");

Callers

nothing calls this directly

Calls 4

as_strMethod · 0.80
enableMethod · 0.80
disableMethod · 0.80
handle_fifo_messagesMethod · 0.80

Tested by

no test coverage detected