-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathexecutor.rs
More file actions
74 lines (63 loc) · 2.5 KB
/
executor.rs
File metadata and controls
74 lines (63 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use async_trait::async_trait;
use crate::prelude::*;
use crate::run::instruments::mongo_tracer::MongoTracer;
use crate::run::runner::executor::Executor;
use crate::run::runner::{ExecutorName, RunData};
use crate::run::{check_system::SystemInfo, config::Config};
use super::setup::install_valgrind;
use super::{helpers::perf_maps::harvest_perf_maps, helpers::venv_compat, measure};
pub struct ValgrindExecutor;
#[async_trait(?Send)]
impl Executor for ValgrindExecutor {
fn name(&self) -> ExecutorName {
ExecutorName::Valgrind
}
async fn setup(&self, system_info: &SystemInfo) -> Result<()> {
// Valgrind / Callgrind is not supported on macOS (notably arm64 macOS).
// Instead of failing fast, allow the executor to run but skip installing
// Valgrind. The measure implementation contains a macOS fallback that
// runs the benchmark without instrumentation so users can still run
// benchmarks locally on macOS.
if cfg!(target_os = "macos") {
warn!(
"Valgrind/Callgrind is not supported on macOS: skipping Valgrind installation. Benchmarks will run without instrumentation."
);
} else {
install_valgrind(system_info).await?;
}
if let Err(error) = venv_compat::symlink_libpython(None) {
warn!("Failed to symlink libpython");
debug!("Script error: {error}");
}
Ok(())
}
async fn run(
&self,
config: &Config,
_system_info: &SystemInfo,
run_data: &RunData,
mongo_tracer: &Option<MongoTracer>,
) -> Result<()> {
// On macOS, callgrind is not available. Let the measure function handle
// the macOS fallback (it will run the benchmark without instrumentation)
// so users can still run benchmarks locally. On non-macOS platforms we
// proceed with the regular Valgrind-based instrumentation.
// TODO: add valgrind version check for non-macOS platforms
if cfg!(target_os = "macos") {
info!(
"Running Valgrind executor on macOS: benchmarks will run without Callgrind instrumentation."
);
}
measure::measure(config, &run_data.profile_folder, mongo_tracer).await?;
Ok(())
}
async fn teardown(
&self,
_config: &Config,
_system_info: &SystemInfo,
run_data: &RunData,
) -> Result<()> {
harvest_perf_maps(&run_data.profile_folder).await?;
Ok(())
}
}