Ver Fonte

Allow specifying how many cores to use and collect timestamps while processing

niels há 1 ano atrás
pai
commit
b8e6a36caf
2 ficheiros alterados com 16 adições e 5 exclusões
  1. 12 1
      responder-bench/src/process.rs
  2. 4 4
      responder-bench/src/run.rs

+ 12 - 1
responder-bench/src/process.rs

@@ -1,4 +1,4 @@
-use std::{fmt::Debug, path::{Path, PathBuf}, fs::File, io::{Read, BufReader, BufRead, Write}, collections::{HashMap, HashSet}, net::Ipv4Addr};
+use std::{fmt::Debug, path::{Path, PathBuf}, fs::File, io::{Read, BufReader, BufRead, Write}, collections::{HashMap, HashSet}, net::Ipv4Addr, time::UNIX_EPOCH};
 use anyhow::{Context, bail, anyhow};
 use clap::Parser;
 use json::JsonValue;
@@ -129,6 +129,7 @@ pub fn process(opts: Options) -> anyhow::Result<()> {
     let zmap_stats_regex = Regex::new(r"^[^\(;]+(?:\(.+left\))?; send: [^\(;]+done \(([\d\.]+) ([KMG]?)p/s avg\); recv: [^\(;]+\(([\d\.]+) ([KMG]?)p/s avg\); drops: [^\(;]+\(([\d\.]+) ([KMG]?)p/s avg\); hitrate: [^;]+$")?;
 
     let run_header_row = [
+        "start_ts", "end_ts",
         "run", "type", "filter-type",
         "subnet_size", "dataset_index", "filter_bits", "bloom_filter_hash_count", "zmap_scanrate",
         "bpf_run_time_total", "bpf_run_count", "bpf_memory_lock",
@@ -285,8 +286,18 @@ pub fn process(opts: Options) -> anyhow::Result<()> {
                             let zmap_stats = zmap_stats(wd_path.join("zmap_stats.txt"), &zmap_stats_regex)
                                 .context(format!("Failed to parse zmap_stats.txt from {:?}", wd_path))?;
 
+                            let start_ts = wd_path.join("zmap_out_ips.txt")
+                                                  .metadata()
+                                                  .context(format!("Failed to get metadata of responder_info.json from {:?}",wd_path))?
+                                                  .created()?.duration_since(UNIX_EPOCH)?.as_millis().to_string();
+                            let end_ts = wd_path.join("zmap_out_ips.txt")
+                                                .metadata()
+                                                .context(format!("Failed to get metadata of responder_info.json from {:?}", wd_path))?
+                                                .modified()?.duration_since(UNIX_EPOCH)?.as_millis().to_string();
+
                             let run_data_row = (|| {
                                 Ok([
+                                    start_ts, end_ts,
                                     run.to_owned(),
                                     test_type.to_owned(),
                                     filter_type.to_owned(),

+ 4 - 4
responder-bench/src/run.rs

@@ -19,6 +19,7 @@ pub const BENCH_LOG_PATH: &str = "log";
 const XDP_LOAD_TIMEOUT_SECS: u64 = 5;
 const HITRATE_ALLOWED_DIFFERENCE: f64 = 0.25;
 const HITRATE_GENERATION_ALLOWED_ATTEMPTS: usize = 50;
+const ALLOCATED_CORES: usize = 6;
 
 const PRIVILEGE_RUNNER: [&str;1] = ["sudo"];
 
@@ -125,13 +126,11 @@ where
 pub fn run() -> Result<(), anyhow::Error> {
     clean().context("Cleaning bench folder")?;
 
-    let cores: u32 = 4;
-
     let seed: u64 = 0x1337133713371337;
 
     let times: u64 = 2;
 
-    let scan_sizes: Vec<u64> = vec![16];//, 24];//,32]; // TODO 8 only for test purposes
+    let scan_sizes: Vec<u64> = vec![21];//, 24];//,32]; // TODO 8 only for test purposes
     // let scan_sizes: Vec<u64> = vec![24];
     // let hit_rates: Vec<f64> = vec![0.001, 0.0032,0.01,0.032,0.1];
     info!("Loading in data sets");
@@ -593,6 +592,7 @@ fn run_zmap(bench_args: BenchArgs, subnet: Ipv4Addr) -> anyhow::Result<process::
         _ => "lo",
     };
     let seed = bench_args.data_args.seed.to_string();
+    let cores = ALLOCATED_CORES.to_string();
     let mut args = Vec::from(PRIVILEGE_RUNNER);
     args.extend_from_slice(&[
         "./zmap",
@@ -602,7 +602,7 @@ fn run_zmap(bench_args: BenchArgs, subnet: Ipv4Addr) -> anyhow::Result<process::
         "--gateway-mac=00:00:00:00:00:00",
         "--output-file", output_file.to_str().unwrap(),
         "--rate", rate_string.as_str(),
-        "--sender-threads=7",
+        "--sender-threads", cores.as_str(),
         "--cooldown-time=1",
         "--seed", seed.as_str(),
         "--blocklist-file=blocklist",