Skip to content

Commit

Permalink
Single now takes batch size argument
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris committed Nov 18, 2024
1 parent 581de90 commit 56197dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod single;
mod tenkrandom;
mod zipf;

#[derive(Debug, Subcommand)]
#[derive(Debug, Subcommand, PartialEq)]
enum TestName {
Create,
TenKRandom,
Expand Down Expand Up @@ -122,6 +122,10 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
async fn main() -> Result<(), Box<dyn Error>> {
let args = Args::parse();

if args.test_name == TestName::Single && args.batch_size > 1000 {
panic!("Single test is not designed to handle batch sizes > 1000");
}

env_logger::Builder::new()
.filter_level(match args.global_opts.log_level.as_str() {
"debug" => LevelFilter::Debug,
Expand Down
15 changes: 10 additions & 5 deletions benchmark/src/single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ pub struct Single;
impl TestRunner for Single {
async fn run(&self, db: &Db, args: &crate::Args) -> Result<(), Box<dyn Error>> {
let start = Instant::now();
let inner_key = Sha256::digest(0u64.to_ne_bytes()).to_vec();
let inner_keys: Vec<_> = (0..args.batch_size)
.map(|i| Sha256::digest(i.to_ne_bytes()))
.collect();
let mut batch_id = 0;

while start.elapsed().as_secs() / 60 < args.global_opts.duration_minutes {
let batch = vec![BatchOp::Put {
key: inner_key.clone(),
value: vec![batch_id as u8],
}];
let batch = inner_keys
.iter()
.map(|key| BatchOp::Put {
key,
value: vec![batch_id as u8],
})
.collect();
let proposal = db.propose(batch).await.expect("proposal should succeed");
proposal.commit().await?;

Expand Down
2 changes: 1 addition & 1 deletion benchmark/src/zipf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::collections::HashSet;
use std::error::Error;
use std::time::Instant;

#[derive(clap::Args, Debug)]
#[derive(clap::Args, Debug, PartialEq)]
pub struct Args {
#[arg(short, long, help = "zipf exponent", default_value_t = 1.2)]
exponent: f64,
Expand Down

0 comments on commit 56197dd

Please sign in to comment.