-
Notifications
You must be signed in to change notification settings - Fork 7
fix: unify environments between the two modes #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| use std::{collections::HashMap, env::consts::ARCH}; | ||
| use std::{collections::HashMap, env::consts::ARCH, path::Path}; | ||
|
|
||
| use lazy_static::lazy_static; | ||
| use crate::run::runner::RunnerMode; | ||
|
|
||
| lazy_static! { | ||
| pub static ref BASE_INJECTED_ENV: HashMap<&'static str, String> = { | ||
| HashMap::from([ | ||
| ("PYTHONHASHSEED", "0".into()), | ||
| ("ARCH", ARCH.into()), | ||
| ("CODSPEED_ENV", "runner".into()), | ||
| ]) | ||
| }; | ||
| pub fn get_base_injected_env( | ||
| mode: RunnerMode, | ||
| profile_folder: &Path, | ||
| ) -> HashMap<&'static str, String> { | ||
| HashMap::from([ | ||
| ("PYTHONHASHSEED", "0".into()), | ||
| ("ARCH", ARCH.into()), | ||
| ("CODSPEED_ENV", "runner".into()), | ||
| ("CODSPEED_RUNNER_MODE", mode.to_string()), | ||
| ( | ||
| "CODSPEED_PROFILE_FOLDER", | ||
| profile_folder.to_string_lossy().to_string(), | ||
| ), | ||
| ]) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,12 @@ | ||
| use crate::prelude::*; | ||
| 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::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::runner::RunnerMode; | ||
| use crate::run::{config::Config, instruments::mongo_tracer::MongoTracer}; | ||
| use lazy_static::lazy_static; | ||
| use std::collections::HashMap; | ||
| use std::env; | ||
| use std::fs::canonicalize; | ||
| use std::path::Path; | ||
|
|
@@ -42,17 +43,20 @@ lazy_static! { | |
| } | ||
|
|
||
| pub fn measure( | ||
| base_env: &HashMap<&str, String>, | ||
| config: &Config, | ||
| profile_folder: &Path, | ||
| mongo_tracer: &Option<MongoTracer>, | ||
| ) -> Result<()> { | ||
| // Create the command | ||
| let mut cmd = Command::new("setarch"); | ||
| cmd.envs(base_env); | ||
| cmd.arg(ARCH).arg("-R"); | ||
| // Configure the environment | ||
| cmd.env( | ||
| cmd.envs(get_base_injected_env( | ||
| RunnerMode::Instrumentation, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have the executor define its So that we do not have to hardcode it here, and instead have it as a method of the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not useful with the valgrind executor since it needs refactoring to be properly implemented. We could drill the mode into |
||
| profile_folder, | ||
| )) | ||
| .env("PYTHONMALLOC", "malloc") | ||
| .env( | ||
| "PATH", | ||
| format!( | ||
| "{}:{}", | ||
|
|
@@ -62,8 +66,7 @@ pub fn measure( | |
| .unwrap(), | ||
| env::var("PATH").unwrap_or_default(), | ||
| ), | ||
| ) | ||
| .env("PYTHONMALLOC", "malloc"); | ||
| ); | ||
|
|
||
| if let Some(cwd) = &config.working_directory { | ||
| let abs_cwd = canonicalize(cwd)?; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import grouping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can cargo fmt handle this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could set this in our repos: https://rust-lang.github.io/rustfmt/?version=v1.6.0&search=granula#Crate%5C%3A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind it's unstable and therefore not able to be put in rustfmt.toml, it needs to be set at IDE level 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(