diff --git a/Cargo.lock b/Cargo.lock index 7fa0d4ed7..00333dccb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -773,7 +773,6 @@ dependencies = [ "tokio-util", "url", "uuid", - "which 8.0.2", "xattr", ] @@ -1209,13 +1208,11 @@ name = "exec-harness" version = "1.4.1" dependencies = [ "anyhow", - "cc", "clap", "env_logger", "humantime", "instrument-hooks-bindings", "log", - "object", "rstest", "runner-shared", "serde", @@ -2446,7 +2443,6 @@ dependencies = [ "runner-shared", "serde", "serde_json", - "static_assertions", "tempfile", "test-log", "test-with", @@ -4444,12 +4440,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "statrs" version = "0.18.0" diff --git a/Cargo.toml b/Cargo.toml index bf1ba4da4..7de37d943 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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"] } diff --git a/crates/exec-harness/Cargo.toml b/crates/exec-harness/Cargo.toml index b7c7a26c0..946d9c43c 100644 --- a/crates/exec-harness/Cargo.toml +++ b/crates/exec-harness/Cargo.toml @@ -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 diff --git a/crates/exec-harness/src/walltime/benchmark_loop.rs b/crates/exec-harness/src/walltime/benchmark_loop.rs index cb8f12eb7..18cd1ed30 100644 --- a/crates/exec-harness/src/walltime/benchmark_loop.rs +++ b/crates/exec-harness/src/walltime/benchmark_loop.rs @@ -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 */ } } diff --git a/crates/exec-harness/src/walltime/config.rs b/crates/exec-harness/src/walltime/config.rs index d04395b69..b6d29d0e0 100644 --- a/crates/exec-harness/src/walltime/config.rs +++ b/crates/exec-harness/src/walltime/config.rs @@ -180,22 +180,21 @@ impl TryFrom 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 diff --git a/crates/memtrack/Cargo.toml b/crates/memtrack/Cargo.toml index 9d3ddcde8..71955fd7c 100644 --- a/crates/memtrack/Cargo.toml +++ b/crates/memtrack/Cargo.toml @@ -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 } diff --git a/crates/memtrack/src/ebpf/events.rs b/crates/memtrack/src/ebpf/events.rs index 753daa0e1..44de03865 100644 --- a/crates/memtrack/src/ebpf/events.rs +++ b/crates/memtrack/src/ebpf/events.rs @@ -164,8 +164,10 @@ pub fn fp_chain(stack_traces: &impl MapCore, stackid: i64) -> Vec { // 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() } diff --git a/crates/runner-shared/benches/memtrack_reader.rs b/crates/runner-shared/benches/memtrack_reader.rs index 4bef13344..619dc0533 100644 --- a/crates/runner-shared/benches/memtrack_reader.rs +++ b/crates/runner-shared/benches/memtrack_reader.rs @@ -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 diff --git a/crates/runner-shared/src/perf_event.rs b/crates/runner-shared/src/perf_event.rs index b93692bd8..0d04e7886 100644 --- a/crates/runner-shared/src/perf_event.rs +++ b/crates/runner-shared/src/perf_event.rs @@ -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()); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7855e6d55..640a93b2a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.88.0" +channel = "1.100.0" components = ["rustfmt", "clippy"] diff --git a/src/executor/memory/executor.rs b/src/executor/memory/executor.rs index dc1bc7e7f..fb15a99aa 100644 --- a/src/executor/memory/executor.rs +++ b/src/executor/memory/executor.rs @@ -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:#}"); } } diff --git a/src/executor/memory/setup.rs b/src/executor/memory/setup.rs index 97ac64d55..929c37009 100644 --- a/src/executor/memory/setup.rs +++ b/src/executor/memory/setup.rs @@ -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() + ); } } } diff --git a/src/executor/orchestrator.rs b/src/executor/orchestrator.rs index e78bc43a2..d4aa929c4 100644 --- a/src/executor/orchestrator.rs +++ b/src/executor/orchestrator.rs @@ -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"); diff --git a/src/executor/shared/module_artifacts/module_symbols.rs b/src/executor/shared/module_artifacts/module_symbols.rs index 6ec2b89ca..f283643c8 100644 --- a/src/executor/shared/module_artifacts/module_symbols.rs +++ b/src/executor/shared/module_artifacts/module_symbols.rs @@ -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 diff --git a/src/executor/wall_time/profiler/perf/mod.rs b/src/executor/wall_time/profiler/perf/mod.rs index 4619ded43..0be24e615 100644 --- a/src/executor/wall_time/profiler/perf/mod.rs +++ b/src/executor/wall_time/profiler/perf/mod.rs @@ -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() ); diff --git a/src/executor/wall_time/profiler/perf/parse_perf_file.rs b/src/executor/wall_time/profiler/perf/parse_perf_file.rs index a3a8505a7..3815fb60f 100644 --- a/src/executor/wall_time/profiler/perf/parse_perf_file.rs +++ b/src/executor/wall_time/profiler/perf/parse_perf_file.rs @@ -124,8 +124,8 @@ pub fn parse_for_memmap2>( // Retrieve the set of PIDs we ended up tracking after processing all records let tracked_pids: HashSet = 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, }; diff --git a/src/executor/wall_time/profiler/perf/perf_executable.rs b/src/executor/wall_time/profiler/perf/perf_executable.rs index 91c8b83ba..4ac8e0f0e 100644 --- a/src/executor/wall_time/profiler/perf/perf_executable.rs +++ b/src/executor/wall_time/profiler/perf/perf_executable.rs @@ -32,32 +32,32 @@ pub fn get_working_perf_executable() -> Option { 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()); } } } diff --git a/src/local_logger/mod.rs b/src/local_logger/mod.rs index 5a8287bbb..e56e312bf 100644 --- a/src/local_logger/mod.rs +++ b/src/local_logger/mod.rs @@ -84,10 +84,10 @@ pub fn suspend_progress_bar R, R>(f: F) -> R { // If the output is a TTY, and there is a spinner, suspend it if *IS_TTY { // Use try_lock to avoid deadlock on reentrant calls - if let Ok(mut spinner) = SPINNER.try_lock() { - if let Some(spinner) = spinner.as_mut() { - return spinner.suspend(f); - } + if let Ok(mut spinner) = SPINNER.try_lock() + && let Some(spinner) = spinner.as_mut() + { + return spinner.suspend(f); } } @@ -149,15 +149,15 @@ impl Log for LocalLogger { pb.finish_and_clear(); // Show completion message with checkmark - if let Ok(mut current) = CURRENT_GROUP_NAME.lock() { - if let Some(name) = current.take() { - let elapsed_str = format_elapsed(elapsed); - eprintln!( - "{} {}", - format_checkmark(&name, true), - style(elapsed_str).dim(), - ); - } + if let Ok(mut current) = CURRENT_GROUP_NAME.lock() + && let Some(name) = current.take() + { + let elapsed_str = format_elapsed(elapsed); + eprintln!( + "{} {}", + format_checkmark(&name, true), + style(elapsed_str).dim(), + ); } } } @@ -396,10 +396,10 @@ pub fn start_spinner(message: &str) { /// Stop and clear the current standalone spinner. pub fn stop_spinner() { - if let Ok(mut spinner) = SPINNER.lock() { - if let Some(pb) = spinner.take() { - pb.finish_and_clear(); - } + if let Ok(mut spinner) = SPINNER.lock() + && let Some(pb) = spinner.take() + { + pb.finish_and_clear(); } } diff --git a/src/local_logger/rolling_buffer/mod.rs b/src/local_logger/rolling_buffer/mod.rs index a60894ae7..9d0bd1c81 100644 --- a/src/local_logger/rolling_buffer/mod.rs +++ b/src/local_logger/rolling_buffer/mod.rs @@ -20,11 +20,11 @@ static ACTIVE_BUFFER: LazyLock>> = LazyLock::new(|| /// Returns `false` when no buffer is active so the caller can fall back to /// plain output. pub(super) fn try_push(text: &str) -> bool { - if let Ok(mut guard) = ACTIVE_BUFFER.lock() { - if let Some(rb) = guard.as_mut() { - rb.push_lines(text); - return true; - } + if let Ok(mut guard) = ACTIVE_BUFFER.lock() + && let Some(rb) = guard.as_mut() + { + rb.push_lines(text); + return true; } false } @@ -316,11 +316,11 @@ impl RollingBufferGuard { } // Suspend the group spinner so it doesn't interfere with rolling output - if let Ok(mut spinner) = SPINNER.lock() { - if let Some(pb) = spinner.take() { - pb.suspend(|| eprintln!()); - pb.finish_and_clear(); - } + if let Ok(mut spinner) = SPINNER.lock() + && let Some(pb) = spinner.take() + { + pb.suspend(|| eprintln!()); + pb.finish_and_clear(); } super::activate_log_deferral(); @@ -342,13 +342,13 @@ impl RollingBufferGuard { if tick_stop.load(Ordering::Relaxed) { break; } - if let Ok(mut guard) = ACTIVE_BUFFER.try_lock() { - if let Some(rb) = guard.as_mut() { - if rb.finished { - break; - } - rb.redraw_title(); + if let Ok(mut guard) = ACTIVE_BUFFER.try_lock() + && let Some(rb) = guard.as_mut() + { + if rb.finished { + break; } + rb.redraw_title(); } } } diff --git a/src/project_config/mod.rs b/src/project_config/mod.rs index 727e19659..9f5514dfe 100644 --- a/src/project_config/mod.rs +++ b/src/project_config/mod.rs @@ -32,10 +32,10 @@ impl ProjectConfig { /// /// Checks for invalid combinations of options, particularly in walltime config fn validate(&self) -> Result<()> { - if let Some(options) = &self.options { - if let Some(walltime) = &options.walltime { - Self::validate_walltime_options(walltime, "root options")?; - } + if let Some(options) = &self.options + && let Some(walltime) = &options.walltime + { + Self::validate_walltime_options(walltime, "root options")?; } Ok(()) } diff --git a/src/run_environment/buildkite/provider.rs b/src/run_environment/buildkite/provider.rs index 4b4840248..217d42419 100644 --- a/src/run_environment/buildkite/provider.rs +++ b/src/run_environment/buildkite/provider.rs @@ -282,7 +282,7 @@ mod tests { assert_eq!(value.as_str().unwrap(), VERSION.to_string()); "[version]" }), - }) + }); }, ); } diff --git a/src/upload/benchmark_display.rs b/src/upload/benchmark_display.rs index e6b882285..13a86ae1f 100644 --- a/src/upload/benchmark_display.rs +++ b/src/upload/benchmark_display.rs @@ -410,7 +410,7 @@ pub fn build_comparison_table(results: &[CompareRunsBenchmarkResult]) -> String ResultComparisonCategory::Untouched => { format!("{}", style("No Change").dim()) } - _ => format!("{}", &result.status), + _ => format!("{}", result.status), }; ComparisonRow { diff --git a/src/upload/profile_archive.rs b/src/upload/profile_archive.rs index 9308810f7..546786780 100644 --- a/src/upload/profile_archive.rs +++ b/src/upload/profile_archive.rs @@ -203,10 +203,10 @@ impl ProfileArchiveContent { impl Drop for ProfileArchiveContent { fn drop(&mut self) { - if let ProfileArchiveContent::UncompressedOnDisk { path } = self { - if path.exists() { - let _ = std::fs::remove_file(path); - } + if let ProfileArchiveContent::UncompressedOnDisk { path } = self + && path.exists() + { + let _ = std::fs::remove_file(path); } } }