Skip to content

Commit 72ad271

Browse files
feat: use introspected node in walltime mode
1 parent befc0e8 commit 72ad271

File tree

8 files changed

+17
-11
lines changed

8 files changed

+17
-11
lines changed

src/run/runner/helpers/introspected_golang/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const INTROSPECTED_GO_SCRIPT: &str = include_str!("go.sh");
55

66
/// Creates the `go` script that will replace the `go` binary while running
77
/// Returns the path to the script folder, which should be added to the PATH environment variable
8-
pub fn setup_introspected_go() -> Result<PathBuf> {
8+
pub fn setup() -> Result<PathBuf> {
99
let script_folder = env::temp_dir().join("codspeed_introspected_go");
1010
std::fs::create_dir_all(&script_folder)?;
1111
let script_path = script_folder.join("go");

src/run/runner/valgrind/helpers/introspected_nodejs/mod.rs renamed to src/run/runner/helpers/introspected_nodejs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const INTROSPECTED_NODE_SCRIPT: &str = include_str!("node.sh");
55

66
/// Creates the `node` script that will replace the `node` binary while running
77
/// Returns the path to the script folder, which should be added to the PATH environment variable
8-
pub fn setup_introspected_nodejs() -> Result<PathBuf> {
8+
pub(crate) fn setup() -> Result<PathBuf> {
99
let script_folder = env::temp_dir().join("codspeed_introspected_node");
1010
std::fs::create_dir_all(&script_folder)?;
1111
let script_path = script_folder.join("node");

src/run/runner/valgrind/helpers/introspected_nodejs/node.sh renamed to src/run/runner/helpers/introspected_nodejs/node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -eo pipefail
33

44
# Custom script to replace node and run with V8 flags that make the execution of the

src/run/runner/helpers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub mod env;
22
pub mod get_bench_command;
33
pub mod introspected_golang;
4+
pub mod introspected_nodejs;
45
pub mod profile_folder;
56
pub mod run_command_with_log_pipe;
67
pub mod setup;
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
pub mod ignored_objects_path;
2-
pub mod introspected_nodejs;
32
pub mod perf_maps;
43
pub mod venv_compat;

src/run/runner/valgrind/measure.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use crate::run::runner::RunnerMode;
33
use crate::run::runner::helpers::env::get_base_injected_env;
44
use crate::run::runner::helpers::get_bench_command::get_bench_command;
55
use crate::run::runner::helpers::introspected_golang;
6+
use crate::run::runner::helpers::introspected_nodejs;
67
use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe;
78
use crate::run::runner::valgrind::helpers::ignored_objects_path::get_objects_path_to_ignore;
8-
use crate::run::runner::valgrind::helpers::introspected_nodejs::setup_introspected_nodejs;
99
use crate::run::{config::Config, instruments::mongo_tracer::MongoTracer};
1010
use lazy_static::lazy_static;
1111
use std::env;
@@ -92,10 +92,10 @@ pub async fn measure(
9292
"PATH",
9393
format!(
9494
"{}:{}:{}",
95-
setup_introspected_nodejs()
95+
introspected_nodejs::setup()
9696
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))?
9797
.to_string_lossy(),
98-
introspected_golang::setup_introspected_go()
98+
introspected_golang::setup()
9999
.map_err(|e| anyhow!("failed to setup Go introspection. {}", e))?
100100
.to_string_lossy(),
101101
env::var("PATH").unwrap_or_default(),

src/run/runner/wall_time/executor.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::run::instruments::mongo_tracer::MongoTracer;
55
use crate::run::runner::executor::Executor;
66
use crate::run::runner::helpers::env::{get_base_injected_env, is_codspeed_debug_enabled};
77
use crate::run::runner::helpers::get_bench_command::get_bench_command;
8-
use crate::run::runner::helpers::introspected_golang::setup_introspected_go;
8+
use crate::run::runner::helpers::introspected_golang;
9+
use crate::run::runner::helpers::introspected_nodejs;
910
use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe;
1011
use crate::run::runner::{ExecutorName, RunData};
1112
use crate::run::{check_system::SystemInfo, config::Config};
@@ -108,11 +109,13 @@ impl WallTimeExecutor {
108109
.collect::<Vec<_>>()
109110
.join("\n");
110111

111-
// We need to intercept the `go` command to ensure we can run it with our custom runner.
112112
let path_env = std::env::var("PATH").unwrap_or_default();
113113
let path_env = format!(
114-
"export PATH={}:{}",
115-
setup_introspected_go()
114+
"export PATH={}:{}:{}",
115+
introspected_nodejs::setup()
116+
.map_err(|e| anyhow!("failed to setup NodeJS introspection. {}", e))?
117+
.to_string_lossy(),
118+
introspected_golang::setup()
116119
.map_err(|e| anyhow!("failed to setup Go introspection. {}", e))?
117120
.to_string_lossy(),
118121
path_env

src/run/runner/wall_time/perf/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ impl PerfRunner {
277277
let mut symbols_by_pid = HashMap::<u32, ProcessSymbols>::new();
278278
let mut unwind_data_by_pid = HashMap::<u32, Vec<UnwindData>>::new();
279279
let mut integration = None;
280+
let mut perf_ping_timeout = 5;
280281

281282
let perf_pid = OnceCell::new();
282283
loop {
@@ -287,6 +288,8 @@ impl PerfRunner {
287288
debug!("Failed to ping perf FIFO, ending perf fifo loop");
288289
break;
289290
}
291+
// Perf has started successfully, we can decrease the timeout for future pings
292+
perf_ping_timeout = 1;
290293

291294
let result = tokio::time::timeout(Duration::from_secs(5), runner_fifo.recv_cmd()).await;
292295
let Ok(Ok(cmd)) = result else {

0 commit comments

Comments
 (0)