From 0394c5144a6cf237ec53cbd694afa29d838519d5 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 17 Apr 2025 11:48:20 +0200 Subject: Fix warnings and general cleanup --- src/benchmark.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'src/benchmark.rs') diff --git a/src/benchmark.rs b/src/benchmark.rs index f7e30c5..c6795df 100644 --- a/src/benchmark.rs +++ b/src/benchmark.rs @@ -7,21 +7,18 @@ use perf_event::{ events::{Event, Hardware}, Builder, Counter, Group, }; -use rand::seq::IteratorRandom; use scx_utils::Topology; use scx_utils::UserExitInfo; use std::mem::MaybeUninit; use std::process; use std::thread; use std::time::{Duration, Instant}; -use std::{collections::HashMap, i32, ops::Range}; +use std::{collections::HashMap, ops::Range}; use std::{fs::File, sync::atomic::AtomicI32}; const SLICE_US: u64 = 5000; const LOG_INTERVAL_MS: u64 = 10; const RESHUFFLE_ROUNDS: usize = 1000; // Number of rounds before changing cpu -const MAX_COUNTERS_AT_ONCE_P_CORE: usize = 7; -const MAX_COUNTERS_AT_ONCE_E_CORE: usize = 6; type Pid = i32; static CPU: AtomicI32 = AtomicI32::new(0); @@ -29,7 +26,6 @@ pub struct BenchmarkScheduler<'a> { bpf: BpfScheduler<'a>, own_pid: Pid, log_path: String, - mode: Mode, p_cores: Range, e_cores: Range, } @@ -161,11 +157,7 @@ impl MeasurementDiff { } impl<'a> BenchmarkScheduler<'a> { - pub fn init( - open_object: &'a mut MaybeUninit, - log_path: &str, - mode: Mode, - ) -> Result { + pub fn init(open_object: &'a mut MaybeUninit, log_path: &str) -> Result { let bpf = BpfScheduler::init( open_object, 0, // exit_dump_len (default) @@ -194,7 +186,6 @@ impl<'a> BenchmarkScheduler<'a> { bpf, own_pid: process::id() as i32, log_path: log_path.to_string(), - mode, p_cores, e_cores, }) @@ -228,11 +219,10 @@ impl<'a> BenchmarkScheduler<'a> { fn start_measurement_thread(&self) -> thread::JoinHandle<()> { let log_path = self.log_path.clone(); - let mode = self.mode.clone(); let e_cores = self.e_cores.clone(); let p_cores = self.p_cores.clone(); thread::spawn(move || { - if let Err(e) = run_measurement_loop(log_path, mode, p_cores.start, e_cores.start) { + if let Err(e) = run_measurement_loop(log_path, p_cores.start, e_cores.start) { eprintln!("Measurement thread error: {:?}", e); } }) @@ -253,14 +243,13 @@ impl<'a> BenchmarkScheduler<'a> { } // Main measurement loop -fn run_measurement_loop(log_path: String, mode: Mode, p_core: i32, e_core: i32) -> Result<()> { +fn run_measurement_loop(log_path: String, p_core: i32, e_core: i32) -> Result<()> { // Define available hardware counters let available_events = define_available_events(); // Initialize CSV writer with header let mut csv_writer = initialize_csv_writer(&log_path, &available_events)?; - let mut rng = rand::rng(); let mut round_counter = 0; let mut cpu_to_monitor = p_core; @@ -284,14 +273,7 @@ fn run_measurement_loop(log_path: String, mode: Mode, p_core: i32, e_core: i32) } }; - // Select random subset of counters - let selected_events = available_events - .iter() - .choose_multiple(&mut rng, MAX_COUNTERS_AT_ONCE_P_CORE); - - //let selected_events = available_events[0..MAX_COUNTERS_AT_ONCE_E_CORE].iter(); - - // println!("Selected {} events for monitoring", selected_events.len()); + let selected_events = available_events.clone(); // Build counters let mut counters = Vec::new(); -- cgit v1.3.1