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
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ tabled = { version = "0.20.0", features = ["ansi"] }
shell-words = "1.1.1"
rmp-serde = "1.3.1"
uuid = { version = "1.23.1", features = ["v4"] }
which = "8.0.2"
crc32fast = "1.5.0"
samply = { path = "crates/samply-codspeed/samply" }
bytes = "1"
Expand Down Expand Up @@ -129,7 +128,6 @@ ipc-channel = "0.20"
itertools = "0.14.0"
rayon = "1.12"
linux-perf-event-reader = "0.10.2" # matches the version linux-perf-data resolves to
perf-event-open-sys = "6.0"
env_logger = "0.11.10"
tempfile = "3.27.0"
object = { version = "0.39", default-features = false, features = ["read_core", "elf"] }
Expand Down
4 changes: 0 additions & 4 deletions crates/exec-harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ serde = { workspace = true }
humantime = "2.3"
runner-shared = { path = "../runner-shared" }
tempfile = { workspace = true }
object = { workspace = true }

[dev-dependencies]
rstest = { workspace = true }

[build-dependencies]
cc = "1"

# Bundled in the runner binary, not released on its own.
[package.metadata.dist]
dist = false
24 changes: 12 additions & 12 deletions crates/exec-harness/src/walltime/benchmark_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,18 @@ where
if let [(start, end)] = warmup_timestamps.as_slice() {
let single_warmup_round_duration_ns = end - start;
match config.max {
Some(RoundOrTime::TimeNs(time_ns)) | Some(RoundOrTime::Both { time_ns, .. }) => {
if time_ns <= single_warmup_round_duration_ns {
info!(
"A single warmup execution ({}) exceeded or met max_time ({}). No more rounds will be performed.",
format_ns(single_warmup_round_duration_ns),
format_ns(time_ns)
);
return Ok(WarmupResult::EarlyReturn {
start: *start,
end: *end,
});
}
Some(RoundOrTime::TimeNs(time_ns)) | Some(RoundOrTime::Both { time_ns, .. })
if time_ns <= single_warmup_round_duration_ns =>
{
info!(
"A single warmup execution ({}) exceeded or met max_time ({}). No more rounds will be performed.",
format_ns(single_warmup_round_duration_ns),
format_ns(time_ns)
);
return Ok(WarmupResult::EarlyReturn {
start: *start,
end: *end,
});
}
_ => { /* No max time constraint */ }
}
Expand Down
27 changes: 13 additions & 14 deletions crates/exec-harness/src/walltime/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,21 @@ impl TryFrom<WalltimeExecutionArgs> for ExecutionOptions {
.context("Invalid min_time")?;

// Validation: min_xxx cannot be greater than max_xxx (for same dimension)
if max_time_ns > 0 {
if let Some(min) = min_time_ns {
if min > max_time_ns {
bail!(
"min_time ({:.2}s) cannot be greater than max_time ({:.2}s)",
min as f64 / 1_000_000_000.0,
max_time_ns as f64 / 1_000_000_000.0
);
}
}
if max_time_ns > 0
&& let Some(min) = min_time_ns
&& min > max_time_ns
{
bail!(
"min_time ({:.2}s) cannot be greater than max_time ({:.2}s)",
min as f64 / 1_000_000_000.0,
max_time_ns as f64 / 1_000_000_000.0
);
}

if let (Some(min), Some(max)) = (args.min_rounds, args.max_rounds) {
if min > max {
bail!("min_rounds ({min}) cannot be greater than max_rounds ({max})");
}
if let (Some(min), Some(max)) = (args.min_rounds, args.max_rounds)
&& min > max
{
bail!("min_rounds ({min}) cannot be greater than max_rounds ({max})");
}

// Build min/max using RoundOrTime enum
Expand Down
1 change: 0 additions & 1 deletion crates/memtrack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ serde_json = { workspace = true }
serde = { workspace = true }
runner-shared = { path = "../runner-shared" }
ipc-channel = { workspace = true }
static_assertions = "1.1"
itertools = { workspace = true }
paste = "1.0.15"
libbpf-rs = { version = "0.26", features = ["vendored"], optional = true }
Expand Down
6 changes: 4 additions & 2 deletions crates/memtrack/src/ebpf/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ pub fn fp_chain(stack_traces: &impl MapCore, stackid: i64) -> Vec<u64> {

// The map value is a fixed-depth array zero-padded past the last frame.
value
.chunks_exact(8)
.map(|word| u64::from_ne_bytes(word.try_into().expect("chunks_exact yields 8 bytes")))
.as_chunks::<8>()
.0
.iter()
.map(|word| u64::from_ne_bytes(*word))
.take_while(|&address| address != 0)
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/runner-shared/benches/memtrack_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn write_artifact(n: usize, payload: Payload, out: impl Write) -> usize {
len: 0x8_0000,
}
} else if i % LIFECYCLE_INTERVAL == 0 {
if (i / LIFECYCLE_INTERVAL) % 2 == 0 {
if (i / LIFECYCLE_INTERVAL).is_multiple_of(2) {
MemtrackEventKind::Fork { parent_pid: PID }
} else {
MemtrackEventKind::Exec
Expand Down
2 changes: 1 addition & 1 deletion crates/runner-shared/src/perf_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl PerfEvent {
fn is_genuine_intel() -> bool {
use std::arch::x86_64::__cpuid;
// CPUID leaf 0: vendor string in EBX,EDX,ECX.
let leaf0 = unsafe { __cpuid(0) };
let leaf0 = __cpuid(0);
let mut vendor = [0u8; 12];
vendor[0..4].copy_from_slice(&leaf0.ebx.to_le_bytes());
vendor[4..8].copy_from_slice(&leaf0.edx.to_le_bytes());
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.88.0"
channel = "1.100.0"
components = ["rustfmt", "clippy"]
30 changes: 15 additions & 15 deletions src/executor/memory/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,21 @@ impl Executor for MemoryExecutor {
}

let data = fifo_data.borrow_mut().take();
if let Some(data) = data {
if let Some(integration) = data.integration {
let results_folder = execution_context.profile_folder.join("results");
if let Err(e) = save_module_artifacts(
&execution_context.profile_folder,
&results_folder,
integration,
&data.bench_pids,
)
.await
{
// The memory results are complete without them; only offline
// stack attribution is lost.
error!("Failed to save memtrack module artifacts: {e:#}");
}
if let Some(data) = data
&& let Some(integration) = data.integration
{
let results_folder = execution_context.profile_folder.join("results");
if let Err(e) = save_module_artifacts(
&execution_context.profile_folder,
&results_folder,
integration,
&data.bench_pids,
)
.await
{
// The memory results are complete without them; only offline
// stack attribution is lost.
error!("Failed to save memtrack module artifacts: {e:#}");
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/executor/memory/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ fn prune_stale_copies(cache_dir: &Path, current: &Path) {
.metadata()
.and_then(|metadata| metadata.modified())
.is_ok_and(|modified| modified.elapsed().is_ok_and(|age| age > STALE_COPY_AGE));
if dir != current && is_stale {
if let Err(e) = std::fs::remove_dir_all(&dir) {
debug!(
"Failed to remove stale memtrack copy {}: {e}",
dir.display()
);
}
if dir != current
&& is_stale
&& let Err(e) = std::fs::remove_dir_all(&dir)
{
debug!(
"Failed to remove stale memtrack copy {}: {e}",
dir.display()
);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/executor/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ impl Orchestrator {
// Install memtrack's copy before any run under sudo, which may create
// a root-owned `~/.cache` (e.g. samply's symbol cache in walltime).
#[cfg(target_os = "linux")]
if modes.contains(&RunnerMode::Memory) {
if let Err(e) = super::memtrack_path() {
debug!("Failed to install memtrack: {e:#}");
}
if modes.contains(&RunnerMode::Memory)
&& let Err(e) = super::memtrack_path()
{
debug!("Failed to install memtrack: {e:#}");
}

start_opened_group!("Running the benchmarks");
Expand Down
8 changes: 4 additions & 4 deletions src/executor/shared/module_artifacts/module_symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl ModuleSymbols {

// Reject ARM ELF "mapping symbols" as does perf
let name = symbol.name.as_str();
if let [b'$', b'a' | b'd' | b't' | b'x', rest @ ..] = name.as_bytes() {
if rest.is_empty() || rest.starts_with(b".") {
return false;
}
if let [b'$', b'a' | b'd' | b't' | b'x', rest @ ..] = name.as_bytes()
&& (rest.is_empty() || rest.starts_with(b"."))
{
return false;
}

true
Expand Down
2 changes: 1 addition & 1 deletion src/executor/wall_time/profiler/perf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Profiler for PerfProfiler {

let raw_command = format!(
"set -o pipefail && {} | cat > {}",
&cmd_builder.as_command_line(),
cmd_builder.as_command_line(),
perf_file_path.to_string_lossy()
);

Expand Down
4 changes: 2 additions & 2 deletions src/executor/wall_time/profiler/perf/parse_perf_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ pub fn parse_for_memmap2<P: AsRef<Path>>(
// Retrieve the set of PIDs we ended up tracking after processing all records
let tracked_pids: HashSet<pid_t> = match pid_filter {
PidFilter::All => loaded_modules_by_path
.iter()
.flat_map(|(_, loaded)| loaded.pids())
.values()
.flat_map(|loaded| loaded.pids())
.collect(),
PidFilter::TrackedPids(tracked) => tracked,
};
Expand Down
48 changes: 24 additions & 24 deletions src/executor/wall_time/profiler/perf/perf_executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,32 @@ pub fn get_working_perf_executable() -> Option<OsString> {
debug!(
"perf command is not functioning correctly, trying to find alternative path using \"{FIND_PERF_CMD}\""
);
if let Ok(perf_path) = Command::new("sh").arg("-c").arg(FIND_PERF_CMD).output() {
if perf_path.status.success() {
let path = String::from_utf8_lossy(&perf_path.stdout)
.trim()
.to_string();
if path.is_empty() {
debug!("No alternative perf path found");
if let Ok(perf_path) = Command::new("sh").arg("-c").arg(FIND_PERF_CMD).output()
&& perf_path.status.success()
{
let path = String::from_utf8_lossy(&perf_path.stdout)
.trim()
.to_string();
if path.is_empty() {
debug!("No alternative perf path found");
return None;
}
debug!("Found perf path: {path}");
// Check if this perf is working by getting its version
if let Ok(version_output) = Command::new(&path).arg("--version").output() {
if !version_output.status.success() {
debug!(
"Failed to get perf version from alternative path. stderr: {}",
String::from_utf8_lossy(&version_output.stderr)
);
return None;
}
debug!("Found perf path: {path}");
// Check if this perf is working by getting its version
if let Ok(version_output) = Command::new(&path).arg("--version").output() {
if !version_output.status.success() {
debug!(
"Failed to get perf version from alternative path. stderr: {}",
String::from_utf8_lossy(&version_output.stderr)
);
return None;
}

let version = String::from_utf8_lossy(&version_output.stdout)
.trim()
.to_string();
debug!("Found perf version from alternative path: {version}");
return Some(path.into());
}

let version = String::from_utf8_lossy(&version_output.stdout)
.trim()
.to_string();
debug!("Found perf version from alternative path: {version}");
return Some(path.into());
}
}
}
Expand Down
Loading
Loading