Skip to content

Commit

Permalink
New benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Aug 8, 2024
1 parent e8c2a9c commit e6a31fe
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 119 deletions.
26 changes: 25 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions lustre-collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,3 @@ tracing.workspace = true
[dev-dependencies]
include_dir.workspace = true
insta.workspace = true
criterion = { version = "0.5", features = ["html_reports"] }

[lib]
bench = false

[[bin]]
name = "lustre_collector"
path = "src/main.rs"
bench = false

[[bench]]
name = "jobstats_slow"
harness = false

[[bench]]
name = "jobstats_fast"
harness = false
49 changes: 0 additions & 49 deletions lustre-collector/benches/jobstats_fast.rs

This file was deleted.

52 changes: 0 additions & 52 deletions lustre-collector/benches/jobstats_slow.rs

This file was deleted.

13 changes: 13 additions & 0 deletions lustrefs-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ const_format = "0.2.32"
include_dir.workspace = true
insta.workspace = true
serde_json = "1"
criterion = { version = "0.5", features = ["html_reports", "async_tokio"] }

[lib]
bench = false

[[bin]]
name = "lustrefs-exporter"
path = "src/main.rs"
bench = false

[[bench]]
name = "jobstats"
harness = false
69 changes: 69 additions & 0 deletions lustrefs-exporter/benches/jobstats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use std::io::BufReader;

use const_format::{formatcp, str_repeat};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use lustrefs_exporter::jobstats::jobstats_stream;

const JOBSTAT_JOB: &str = r#"
- job_id: "FAKE_JOB"
snapshot_time: 1720516680
read_bytes: { samples: 0, unit: bytes, min: 0, max: 0, sum: 0, sumsq: 0 }
write_bytes: { samples: 52, unit: bytes, min: 4096, max: 475136, sum: 5468160, sumsq: 1071040692224 }
read: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
write: { samples: 52, unit: usecs, min: 12, max: 40081, sum: 692342, sumsq: 17432258604 }
getattr: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
setattr: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
punch: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
sync: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
destroy: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
create: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
statfs: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
get_info: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
set_info: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
quotactl: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }
prealloc: { samples: 0, unit: usecs, min: 0, max: 0, sum: 0, sumsq: 0 }"#;

#[allow(long_running_const_eval)]
const INPUT_100_JOBS: &str = formatcp!(
r#"obdfilter.ds002-OST0000.job_stats=
job_stats:{}"#,
str_repeat!(JOBSTAT_JOB, 100)
);

#[allow(long_running_const_eval)]
const INPUT_1000_JOBS: &str = formatcp!(
r#"obdfilter.ds002-OST0000.job_stats=
job_stats:{}"#,
str_repeat!(JOBSTAT_JOB, 1000)
);

async fn parse_synthetic_yaml(input: &'static str, len: usize) {
let f = BufReader::with_capacity(128 * 1_024, input.as_bytes());

let (fut, mut rx) = jobstats_stream(f);

let mut cnt = 0;

while rx.recv().await.is_some() {
cnt += 1;
}

fut.await.unwrap();
}

fn criterion_benchmark_fast(c: &mut Criterion) {
c.bench_function("jobstats 100", |b| {
b.to_async(tokio::runtime::Builder::new_multi_thread().build().unwrap())
.iter(|| black_box(parse_synthetic_yaml(INPUT_100_JOBS, 100)))
});
c.bench_function("jobstats 1000", |b| {
b.to_async(tokio::runtime::Builder::new_multi_thread().build().unwrap())
.iter(|| black_box(parse_synthetic_yaml(INPUT_1000_JOBS, 1000)))
});
}
criterion_group! {
name = benches;
config = Criterion::default();
targets = criterion_benchmark_fast
}
criterion_main!(benches);

0 comments on commit e6a31fe

Please sign in to comment.