Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/run/runner/helpers/introspected_golang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf> {
pub fn setup() -> Result<PathBuf> {
let script_folder = env::temp_dir().join("codspeed_introspected_go");
std::fs::create_dir_all(&script_folder)?;
let script_path = script_folder.join("go");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf> {
pub(crate) fn setup() -> Result<PathBuf> {
let script_folder = env::temp_dir().join("codspeed_introspected_node");
std::fs::create_dir_all(&script_folder)?;
let script_path = script_folder.join("node");
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions src/run/runner/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 0 additions & 1 deletion src/run/runner/valgrind/helpers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod ignored_objects_path;
pub mod introspected_nodejs;
pub mod perf_maps;
pub mod venv_compat;
6 changes: 3 additions & 3 deletions src/run/runner/valgrind/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
11 changes: 7 additions & 4 deletions src/run/runner/wall_time/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -108,11 +109,13 @@ impl WallTimeExecutor {
.collect::<Vec<_>>()
.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
Expand Down
8 changes: 7 additions & 1 deletion src/run/runner/wall_time/perf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,19 @@ impl PerfRunner {
let mut symbols_by_pid = HashMap::<u32, ProcessSymbols>::new();
let mut unwind_data_by_pid = HashMap::<u32, Vec<UnwindData>>::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 {
Expand Down