Skip to content

Commit 4a524d8

Browse files
committed
wip: expose all env vars
1 parent 67150ac commit 4a524d8

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/run/runner/wall_time/executor.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ use super::perf::PerfRunner;
22
use crate::prelude::*;
33
use crate::run::instruments::mongo_tracer::MongoTracer;
44
use crate::run::runner::executor::Executor;
5-
use crate::run::runner::helpers::env::get_base_injected_env;
65
use crate::run::runner::helpers::get_bench_command::get_bench_command;
76
use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe;
8-
use crate::run::runner::{ExecutorName, RunData, RunnerMode};
7+
use crate::run::runner::{ExecutorName, RunData};
98
use crate::run::{check_system::SystemInfo, config::Config};
109
use async_trait::async_trait;
1110
use std::fs::canonicalize;
@@ -55,19 +54,14 @@ impl Executor for WallTimeExecutor {
5554
// spawned child process which won't work if we use a different shell.
5655
let mut cmd = Command::new("bash");
5756

58-
cmd.envs(get_base_injected_env(
59-
RunnerMode::Walltime,
60-
&run_data.profile_folder,
61-
));
62-
6357
if let Some(cwd) = &config.working_directory {
6458
let abs_cwd = canonicalize(cwd)?;
6559
cmd.current_dir(abs_cwd);
6660
}
6761

6862
let bench_cmd = get_bench_command(config)?;
6963
let status = if let Some(perf) = &self.perf {
70-
perf.run(cmd, &bench_cmd).await
64+
perf.run(cmd, &bench_cmd, run_data).await
7165
} else {
7266
cmd.args(["-c", &bench_cmd]);
7367
debug!("cmd: {:?}", cmd);

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#![cfg_attr(not(unix), allow(dead_code, unused_mut))]
22

33
use crate::prelude::*;
4+
use crate::run::runner::helpers::env::get_base_injected_env;
45
use crate::run::runner::helpers::run_command_with_log_pipe::run_command_with_log_pipe_and_callback;
56
use crate::run::runner::helpers::setup::run_with_sudo;
67
use crate::run::runner::valgrind::helpers::ignored_objects_path::get_objects_path_to_ignore;
78
use crate::run::runner::valgrind::helpers::perf_maps::harvest_perf_maps_for_pids;
9+
use crate::run::runner::RunData;
10+
use crate::run::RunnerMode;
811
use anyhow::Context;
912
use fifo::{PerfFifo, RunnerFifo};
1013
use futures::stream::FuturesUnordered;
@@ -72,7 +75,12 @@ impl PerfRunner {
7275
}
7376
}
7477

75-
pub async fn run(&self, mut cmd: Command, bench_cmd: &str) -> anyhow::Result<ExitStatus> {
78+
pub async fn run(
79+
&self,
80+
mut cmd: Command,
81+
bench_cmd: &str,
82+
run_data: &RunData,
83+
) -> anyhow::Result<ExitStatus> {
7684
let perf_fifo = PerfFifo::new()?;
7785
let runner_fifo = RunnerFifo::new()?;
7886

@@ -109,15 +117,18 @@ impl PerfRunner {
109117
}
110118
};
111119

112-
let runner_mode = std::env::var("CODSPEED_RUNNER_MODE").unwrap_or_default();
113-
let codspeed_env = std::env::var("CODSPEED_ENV").unwrap_or_default();
120+
let setenv = get_base_injected_env(RunnerMode::Walltime, &run_data.profile_folder)
121+
.into_iter()
122+
.map(|(env, value)| format!("--setenv={env}={value}"))
123+
.join(" ");
124+
114125
let uid = nix::unistd::Uid::current().as_raw();
115126
let gid = nix::unistd::Gid::current().as_raw();
116127
cmd.args([
117128
"-c",
118129
&format!(
119130
"sudo perf record {quiet_flag} --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- \
120-
systemd-run --scope --slice=codspeed.slice --same-dir --setenv=CODSPEED_ENV={codspeed_env} --setenv=CODSPEED_RUNNER_MODE={runner_mode} --uid={uid} --gid={gid} -- {bench_cmd}",
131+
systemd-run --scope --slice=codspeed.slice --same-dir --uid={uid} --gid={gid} {setenv} -- {bench_cmd}",
121132
perf_fifo.ctl_fifo_path.to_string_lossy(),
122133
perf_fifo.ack_fifo_path.to_string_lossy(),
123134
perf_file.path().to_string_lossy(),

0 commit comments

Comments
 (0)