diff --git a/betree/haura-benchmarks/run.sh b/betree/haura-benchmarks/run.sh index 453aa48b..4a930528 100755 --- a/betree/haura-benchmarks/run.sh +++ b/betree/haura-benchmarks/run.sh @@ -83,13 +83,13 @@ function tiered() { } function scientific_evaluation() { - export BETREE__ALLOC_STRATEGY='[[0],[1],[],[]]' - run "$RUN_IDENT" scientific_evaluation_id_alloc evaluation-read 30 + # Invocation: + run "$RUN_IDENT" random_evaluation_read evaluation-read 30 $((25 * 1024 * 1024 * 1024)) $((8192)) $((1 * 1024)) $((12 * 1024 * 1024)) } function evaluation_rw() { - export BETREE__ALLOC_STRATEGY='[[0],[1],[],[]]' - run "$RUN_IDENT" file_system_three evaluation-rw + # Invocation: + run "$RUN_IDENT" random_evaluation_rw evaluation-rw 30 $((25 * 1024 * 1024 * 1024)) $((8192)) $((1 * 1024)) $((12 * 1024 * 1024)) } function filesystem_zip() { diff --git a/betree/haura-benchmarks/src/main.rs b/betree/haura-benchmarks/src/main.rs index c270599e..b92d3f37 100644 --- a/betree/haura-benchmarks/src/main.rs +++ b/betree/haura-benchmarks/src/main.rs @@ -22,15 +22,23 @@ enum Mode { Checkpoints, Filesystem, FilesystemZip { - path: PathBuf + path: PathBuf, }, EvaluationRead { #[structopt(default_value = "120")] runtime: u64, + size: u64, + samples: u64, + min_size: u64, + max_size: u64, }, EvaluationRW { #[structopt(default_value = "120")] runtime: u64, + size: u64, + samples: u64, + min_size: u64, + max_size: u64, }, Zip { n_clients: u32, @@ -83,14 +91,40 @@ fn run_all(mode: Mode) -> Result<(), Box> { filesystem_zip::run(client, path)?; control.database.write().sync()?; } - Mode::EvaluationRead { runtime } => { + Mode::EvaluationRead { + runtime, + size, + samples, + min_size, + max_size, + } => { let client = control.client(0, b"scientific_evaluation"); - scientific_evaluation::run_read(client, runtime)?; + let config = scientific_evaluation::EvaluationConfig { + runtime, + size, + samples, + min_size, + max_size, + }; + scientific_evaluation::run_read(client, config)?; control.database.write().sync()?; } - Mode::EvaluationRW { runtime } => { + Mode::EvaluationRW { + runtime, + size, + samples, + min_size, + max_size, + } => { let client = control.client(0, b"scientific_evaluation"); - scientific_evaluation::run_read_write(client, runtime)?; + let config = scientific_evaluation::EvaluationConfig { + runtime, + size, + samples, + min_size, + max_size, + }; + scientific_evaluation::run_read_write(client, config)?; control.database.write().sync()?; } Mode::Zip { diff --git a/betree/haura-benchmarks/src/scientific_evaluation.rs b/betree/haura-benchmarks/src/scientific_evaluation.rs index be75b323..47086a80 100644 --- a/betree/haura-benchmarks/src/scientific_evaluation.rs +++ b/betree/haura-benchmarks/src/scientific_evaluation.rs @@ -3,35 +3,39 @@ use betree_perf::*; use betree_storage_stack::StoragePreference; use rand::Rng; -use std::{error::Error, io::{Write, Seek}}; +use std::{ + error::Error, + io::{Seek, Write}, +}; -const OBJECT_SIZE: u64 = 25 * 1024 * 1024 * 1024; -const MIN_FETCH_SIZE: u64 = 1 * 1024; -const MAX_FETCH_SIZE: u64 = 12 * 1024 * 1024; -const N_POSITIONS: u64 = 1024; // E(sum N_POSITIONS_size) = 3GiB const OBJ_NAME: &[u8] = b"important_research"; -fn gen_positions(client: &mut Client) -> Vec<(u64, u64)> { +pub struct EvaluationConfig { + pub runtime: u64, + pub size: u64, + pub samples: u64, + pub min_size: u64, + pub max_size: u64, +} + +fn gen_positions(client: &mut Client, config: &EvaluationConfig) -> Vec<(u64, u64)> { let mut positions = vec![]; - for _ in 0..N_POSITIONS { - let start = client.rng.gen_range(0..OBJECT_SIZE); - let length = client.rng.gen_range(MIN_FETCH_SIZE..MAX_FETCH_SIZE); - positions.push(( - start, - length.clamp(0, OBJECT_SIZE.saturating_sub(start)), - )); + for _ in 0..config.samples { + let start = client.rng.gen_range(0..config.size); + let length = client.rng.gen_range(config.min_size..config.max_size); + positions.push((start, length.clamp(0, config.size.saturating_sub(start)))); } positions } -fn prepare_store(client: &mut Client) -> Result<(), Box> { +fn prepare_store(client: &mut Client, config: &EvaluationConfig) -> Result<(), Box> { let start = std::time::Instant::now(); let (obj, _info) = client .object_store .open_or_create_object_with_pref(b"important_research", StoragePreference::SLOW)?; let mut cursor = obj.cursor_with_pref(StoragePreference::SLOW); - with_random_bytes(&mut client.rng, OBJECT_SIZE, 8 * 1024 * 1024, |b| { + with_random_bytes(&mut client.rng, config.size, 8 * 1024 * 1024, |b| { cursor.write_all(b) })?; println!("Initial write took {}s", start.elapsed().as_secs()); @@ -39,11 +43,11 @@ fn prepare_store(client: &mut Client) -> Result<(), Box> { Ok(()) } -pub fn run_read(mut client: Client, runtime: u64) -> Result<(), Box> { +pub fn run_read(mut client: Client, config: EvaluationConfig) -> Result<(), Box> { println!("running scientific_evaluation"); // Generate positions to read - let positions = gen_positions(&mut client); - prepare_store(&mut client)?; + let positions = gen_positions(&mut client, &config); + prepare_store(&mut client, &config)?; let (obj, _info) = client .object_store @@ -51,20 +55,21 @@ pub fn run_read(mut client: Client, runtime: u64) -> Result<(), Box> .expect("Object was just created, but can't be opened!"); let start = std::time::Instant::now(); - let mut buf = vec![0; MAX_FETCH_SIZE as usize]; + let mut buf = vec![0; config.max_size as usize]; let f = std::fs::OpenOptions::new() .write(true) .create(true) .open("evaluation_read.csv")?; let mut w = std::io::BufWriter::new(f); w.write_all(b"offset,size,latency_ns\n")?; + for (pos, len) in positions.iter().cycle() { // Read data as may be done in some evaluation where only parts of a // database file are read in. let t = std::time::Instant::now(); obj.read_at(&mut buf[..*len as usize], *pos).unwrap(); w.write_fmt(format_args!("{pos},{len},{}", t.elapsed().as_nanos()))?; - if start.elapsed().as_secs() >= runtime { + if start.elapsed().as_secs() >= config.runtime { break; } } @@ -72,11 +77,11 @@ pub fn run_read(mut client: Client, runtime: u64) -> Result<(), Box> Ok(()) } -pub fn run_read_write(mut client: Client, runtime: u64) -> Result<(), Box> { +pub fn run_read_write(mut client: Client, config: EvaluationConfig) -> Result<(), Box> { println!("running scientific_evaluation"); // Generate positions to read - let positions = gen_positions(&mut client); - prepare_store(&mut client)?; + let positions = gen_positions(&mut client, &config); + prepare_store(&mut client, &config)?; let (obj, _info) = client .object_store @@ -85,7 +90,7 @@ pub fn run_read_write(mut client: Client, runtime: u64) -> Result<(), Box Result<(), Box= runtime { + if start.elapsed().as_secs() >= config.runtime { break; } }