Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/cli/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ fn build_orchestrator_config(
telemetry: false,
},
walltime_unwinding: args.shared.profiler_run_args.walltime.resolve_unwinding(),
walltime_sampling_rate_hz: args
.shared
.profiler_run_args
.walltime
.walltime_sampling_rate_hz,
enable_profiler: args.shared.profiler_run_args.resolve_enable_profiler(),
walltime_profiler: args.shared.walltime_profiler,
simulation_tool: args.shared.simulation_tool.unwrap_or_default(),
Expand Down
7 changes: 7 additions & 0 deletions src/cli/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ impl RunArgs {
use super::experimental::ExperimentalArgs;
use super::{ProfilerRunArgs, WalltimeRunArgs};
use crate::RunnerMode;
use crate::executor::config::DEFAULT_WALLTIME_SAMPLING_RATE_HZ;

Self {
shared: ExecAndRunSharedArgs {
Expand Down Expand Up @@ -80,6 +81,7 @@ impl RunArgs {
walltime: WalltimeRunArgs {
walltime_unwinding_mode: None,
perf_unwinding_mode: None,
walltime_sampling_rate_hz: DEFAULT_WALLTIME_SAMPLING_RATE_HZ,
},
},
experimental: ExperimentalArgs {
Expand Down Expand Up @@ -130,6 +132,11 @@ fn build_orchestrator_config(
modes,
instruments,
walltime_unwinding: args.shared.profiler_run_args.walltime.resolve_unwinding(),
walltime_sampling_rate_hz: args
.shared
.profiler_run_args
.walltime
.walltime_sampling_rate_hz,
enable_profiler: args.shared.profiler_run_args.resolve_enable_profiler(),
walltime_profiler: args.shared.walltime_profiler,
simulation_tool: args.shared.simulation_tool.unwrap_or_default(),
Expand Down
15 changes: 14 additions & 1 deletion src/cli/shared.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use super::experimental::ExperimentalArgs;
use crate::VERSION;
use crate::executor::config::{SimulationTool, WalltimeProfiler, WalltimeUnwinding};
use crate::executor::config::{
DEFAULT_WALLTIME_SAMPLING_RATE_HZ, SimulationTool, WalltimeProfiler, WalltimeUnwinding,
};
use crate::prelude::*;
use crate::run_environment::interfaces::RepositoryProvider;
use crate::runner_mode::{RunnerMode, load_shell_session_mode};
Expand Down Expand Up @@ -242,6 +244,17 @@ pub struct WalltimeRunArgs {
/// Deprecated alias for --walltime-unwinding-mode / CODSPEED_WALLTIME_UNWINDING_MODE.
#[arg(long, env = "CODSPEED_PERF_UNWINDING_MODE", hide = true, value_parser = parse_walltime_unwinding)]
pub perf_unwinding_mode: Option<WalltimeUnwinding>,

/// Walltime profiler samples per second. Higher rates give more samples for
/// short functions, at the cost of more profiling overhead.
#[arg(
long = "walltime-sampling-rate",
env = "CODSPEED_WALLTIME_SAMPLING_RATE",
value_name = "HZ",
default_value_t = DEFAULT_WALLTIME_SAMPLING_RATE_HZ,
value_parser = clap::value_parser!(u32).range(1..)
)]
pub walltime_sampling_rate_hz: u32,
Comment thread
not-matthias marked this conversation as resolved.
Resolved
}

impl WalltimeRunArgs {
Expand Down
10 changes: 10 additions & 0 deletions src/executor/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use std::collections::HashMap;
use std::path::PathBuf;
use url::Url;

/// Default walltime profiler sampling rate (Hz). A prime number to avoid
/// synchronization with periodic tasks.
pub const DEFAULT_WALLTIME_SAMPLING_RATE_HZ: u32 = 997;

/// A benchmark target from project configuration.
///
/// Defines how a benchmark is executed:
Expand Down Expand Up @@ -92,6 +96,8 @@ pub struct OrchestratorConfig {
pub enable_profiler: bool,
/// Explicit unwinding settings; None preserves the profiler's automatic selection.
pub walltime_unwinding: Option<WalltimeUnwinding>,
/// Walltime profiler samples per second.
pub walltime_sampling_rate_hz: u32,
/// Profiler override for walltime mode (if None, selected based on the platform)
pub walltime_profiler: Option<WalltimeProfiler>,

Expand Down Expand Up @@ -146,6 +152,8 @@ pub struct ExecutorConfig {
pub enable_profiler: bool,
/// Explicit unwinding settings; None preserves the profiler's automatic selection.
pub walltime_unwinding: Option<WalltimeUnwinding>,
/// Walltime profiler samples per second.
pub walltime_sampling_rate_hz: u32,

pub simulation_tool: SimulationTool,

Expand Down Expand Up @@ -242,6 +250,7 @@ impl OrchestratorConfig {
instruments: self.instruments.clone(),
enable_profiler: self.enable_profiler,
walltime_unwinding: self.walltime_unwinding,
walltime_sampling_rate_hz: self.walltime_sampling_rate_hz,
simulation_tool: self.simulation_tool,
skip_run: self.skip_run,
skip_setup: self.skip_setup,
Expand Down Expand Up @@ -276,6 +285,7 @@ impl OrchestratorConfig {
modes: vec![RunnerMode::Simulation],
instruments: Instruments::test(),
walltime_unwinding: None,
walltime_sampling_rate_hz: DEFAULT_WALLTIME_SAMPLING_RATE_HZ,
walltime_profiler: None,
enable_profiler: false,
simulation_tool: SimulationTool::default(),
Expand Down
4 changes: 0 additions & 4 deletions src/executor/wall_time/profiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ mod unwinding;

const WALLTIME_METADATA_CURRENT_VERSION: u64 = 1;

/// Sampling rate (Hz) shared by all walltime profilers. A prime number to
/// avoid synchronization with periodic tasks.
pub(super) const SAMPLING_RATE_HZ: u32 = 997;

/// Warning shown when walltime profiling ran but no benchmarks were detected.
pub(super) const NO_BENCHMARKS_DETECTED_WARNING: &str = "Walltime profiling is enabled, but failed to detect benchmarks. \
If you wish to disable this warning, set CODSPEED_PROFILER_ENABLED=false";
Expand Down
3 changes: 1 addition & 2 deletions src/executor/wall_time/profiler/perf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::executor::shared::fifo::FifoBenchmarkData;
use crate::executor::shared::module_artifacts::save_artifacts;
use crate::executor::wall_time::profiler::NO_BENCHMARKS_DETECTED_WARNING;
use crate::executor::wall_time::profiler::Profiler;
use crate::executor::wall_time::profiler::SAMPLING_RATE_HZ;
use crate::executor::wall_time::profiler::WALLTIME_METADATA_CURRENT_VERSION;
use crate::executor::wall_time::profiler::perf::perf_executable::get_working_perf_executable;
use crate::executor::wall_time::profiler::unwinding::resolve_unwinding;
Expand Down Expand Up @@ -123,7 +122,7 @@ impl Profiler for PerfProfiler {
// Required for matching the markers and URIs to the samples.
"-k",
"CLOCK_MONOTONIC",
&format!("--freq={SAMPLING_RATE_HZ}"),
&format!("--freq={}", config.walltime_sampling_rate_hz),
"--delay=-1",
"-g",
"--user-callchains",
Expand Down
3 changes: 1 addition & 2 deletions src/executor/wall_time/profiler/samply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use std::path::Path;
use std::path::PathBuf;

use super::NO_BENCHMARKS_DETECTED_WARNING;
use super::SAMPLING_RATE_HZ;
use super::WALLTIME_METADATA_CURRENT_VERSION;

const SAMPLY_OUTPUT_FILE_NAME: &str = "samply-profile.json.gz";
Expand Down Expand Up @@ -101,7 +100,7 @@ impl Profiler for SamplyProfiler {
"--no-open".into(),
"--save-only".into(),
"--rate".into(),
SAMPLING_RATE_HZ.to_string().into(),
config.walltime_sampling_rate_hz.to_string().into(),
"-o".into(),
output_path.clone().into(),
];
Expand Down
Loading