diff --git a/src/run/runner/helpers/introspected_golang/mod.rs b/src/run/runner/helpers/introspected_golang/mod.rs index 02e03aa7..9a3aeb93 100644 --- a/src/run/runner/helpers/introspected_golang/mod.rs +++ b/src/run/runner/helpers/introspected_golang/mod.rs @@ -5,7 +5,7 @@ const INTROSPECTED_GO_SCRIPT: &str = include_str!("go.sh"); /// Creates the `go` script that will replace the `go` binary while running /// Returns the path to the script folder, which should be added to the PATH environment variable -pub fn setup_introspected_go() -> Result { +pub fn setup() -> Result { let script_folder = env::temp_dir().join("codspeed_introspected_go"); std::fs::create_dir_all(&script_folder)?; let script_path = script_folder.join("go"); diff --git a/src/run/runner/valgrind/helpers/introspected_nodejs/mod.rs b/src/run/runner/helpers/introspected_nodejs/mod.rs similarity index 93% rename from src/run/runner/valgrind/helpers/introspected_nodejs/mod.rs rename to src/run/runner/helpers/introspected_nodejs/mod.rs index 047bc623..ab663c56 100644 --- a/src/run/runner/valgrind/helpers/introspected_nodejs/mod.rs +++ b/src/run/runner/helpers/introspected_nodejs/mod.rs @@ -5,7 +5,7 @@ const INTROSPECTED_NODE_SCRIPT: &str = include_str!("node.sh"); /// Creates the `node` script that will replace the `node` binary while running /// Returns the path to the script folder, which should be added to the PATH environment variable -pub fn setup_introspected_nodejs() -> Result { +pub(crate) fn setup() -> Result { let script_folder = env::temp_dir().join("codspeed_introspected_node"); std::fs::create_dir_all(&script_folder)?; let script_path = script_folder.join("node"); diff --git a/src/run/runner/valgrind/helpers/introspected_nodejs/node.sh b/src/run/runner/helpers/introspected_nodejs/node.sh similarity index 99% rename from src/run/runner/valgrind/helpers/introspected_nodejs/node.sh rename to src/run/runner/helpers/introspected_nodejs/node.sh index 8a8fa66b..7292de58 100644 --- a/src/run/runner/valgrind/helpers/introspected_nodejs/node.sh +++ b/src/run/runner/helpers/introspected_nodejs/node.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eo pipefail # Custom script to replace node and run with V8 flags that make the execution of the diff --git a/src/run/runner/helpers/mod.rs b/src/run/runner/helpers/mod.rs index 0b8d507d..30bf0a32 100644 --- a/src/run/runner/helpers/mod.rs +++ b/src/run/runner/helpers/mod.rs @@ -1,6 +1,7 @@ pub mod env; pub mod get_bench_command; pub mod introspected_golang; +pub mod introspected_nodejs; pub mod profile_folder; pub mod run_command_with_log_pipe; pub mod setup; diff --git a/src/run/runner/valgrind/helpers/mod.rs b/src/run/runner/valgrind/helpers/mod.rs index 627f11d7..5001151a 100644 --- a/src/run/runner/valgrind/helpers/mod.rs +++ b/src/run/runner/valgrind/helpers/mod.rs @@ -1,4 +1,3 @@ pub mod ignored_objects_path; -pub mod introspected_nodejs; pub mod perf_maps; pub mod venv_compat; diff --git a/src/run/runner/valgrind/measure.rs b/src/run/runner/valgrind/measure.rs index 6c5a12ac..262e471b 100644 --- a/src/run/runner/valgrind/measure.rs +++ b/src/run/runner/valgrind/measure.rs @@ -3,9 +3,9 @@ use crate::run::runner::RunnerMode; use crate::run::runner::helpers::env::get_base_injected_env; use crate::run::runner::helpers::get_bench_command::get_bench_command; use crate::run::runner::helpers::introspected_golang; +use crate::run::runner::helpers::introspected_nodejs; use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe; use crate::run::runner::valgrind::helpers::ignored_objects_path::get_objects_path_to_ignore; -use crate::run::runner::valgrind::helpers::introspected_nodejs::setup_introspected_nodejs; use crate::run::{config::Config, instruments::mongo_tracer::MongoTracer}; use lazy_static::lazy_static; use std::env; @@ -92,10 +92,10 @@ pub async fn measure( "PATH", format!( "{}:{}:{}", - setup_introspected_nodejs() + introspected_nodejs::setup() .map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))? .to_string_lossy(), - introspected_golang::setup_introspected_go() + introspected_golang::setup() .map_err(|e| anyhow!("failed to setup Go introspection. {}", e))? .to_string_lossy(), env::var("PATH").unwrap_or_default(), diff --git a/src/run/runner/wall_time/executor.rs b/src/run/runner/wall_time/executor.rs index c41c60e9..f89539e4 100644 --- a/src/run/runner/wall_time/executor.rs +++ b/src/run/runner/wall_time/executor.rs @@ -5,7 +5,8 @@ use crate::run::instruments::mongo_tracer::MongoTracer; use crate::run::runner::executor::Executor; use crate::run::runner::helpers::env::{get_base_injected_env, is_codspeed_debug_enabled}; use crate::run::runner::helpers::get_bench_command::get_bench_command; -use crate::run::runner::helpers::introspected_golang::setup_introspected_go; +use crate::run::runner::helpers::introspected_golang; +use crate::run::runner::helpers::introspected_nodejs; use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe; use crate::run::runner::{ExecutorName, RunData}; use crate::run::{check_system::SystemInfo, config::Config}; @@ -108,11 +109,13 @@ impl WallTimeExecutor { .collect::>() .join("\n"); - // We need to intercept the `go` command to ensure we can run it with our custom runner. let path_env = std::env::var("PATH").unwrap_or_default(); let path_env = format!( - "export PATH={}:{}", - setup_introspected_go() + "export PATH={}:{}:{}", + introspected_nodejs::setup() + .map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))? + .to_string_lossy(), + introspected_golang::setup() .map_err(|e| anyhow!("failed to setup Go introspection. {}", e))? .to_string_lossy(), path_env diff --git a/src/run/runner/wall_time/perf/mod.rs b/src/run/runner/wall_time/perf/mod.rs index 33a71aa8..6d2d95c2 100644 --- a/src/run/runner/wall_time/perf/mod.rs +++ b/src/run/runner/wall_time/perf/mod.rs @@ -277,13 +277,19 @@ impl PerfRunner { let mut symbols_by_pid = HashMap::::new(); let mut unwind_data_by_pid = HashMap::>::new(); let mut integration = None; + let mut perf_ping_timeout = 5; let perf_pid = OnceCell::new(); loop { - let perf_ping = tokio::time::timeout(Duration::from_secs(1), perf_fifo.ping()).await; + let perf_ping = + tokio::time::timeout(Duration::from_secs(perf_ping_timeout), perf_fifo.ping()) + .await; if let Ok(Err(_)) | Err(_) = perf_ping { + debug!("Failed to ping perf FIFO, ending perf fifo loop"); break; } + // Perf has started successfully, we can decrease the timeout for future pings + perf_ping_timeout = 1; let result = tokio::time::timeout(Duration::from_secs(5), runner_fifo.recv_cmd()).await; let Ok(Ok(cmd)) = result else {