Files
cubelinux-2/cube-mvw/src/main.rs
T

36 lines
1.6 KiB
Rust

use cube_mvw::MvwBackend;
use cubecoords::Czyx;
use std::path::Path;
use std::time::Instant;
use std::thread;
fn bench(mode: &str) -> f64 {
let b = Path::new("/tmp/mvw-gc");
for i in 0..16 { std::fs::remove_file(format!("{}-s{}.log", b.display(), i)).ok(); std::fs::remove_file(format!("{}-s{}.ckpt", b.display(), i)).ok(); }
let back = MvwBackend::open(16, b).unwrap();
let threads = 8usize; let per = 4000u64; let n = (threads as f64) * per as f64;
let t = Instant::now();
thread::scope(|sc| {
for th in 0..threads {
let back = &back;
sc.spawn(move || for i in 0..per {
let k = Czyx::unpack_u32(((th as u64 * per + i) as u32) << 8 | 1);
back.put_shared(k, vec![i as u8; 16]);
});
}
});
if mode == "batch" { back.commit().unwrap(); }
let s = t.elapsed().as_secs_f64();
for i in 0..16 { std::fs::remove_file(format!("{}-s{}.log", b.display(), i)).ok(); std::fs::remove_file(format!("{}-s{}.ckpt", b.display(), i)).ok(); }
n / s / 1e3
}
fn main() {
let per_op = bench("per_op");
let batch = bench("batch");
println!("cube-mvw durable write throughput (8 threads x 4000, 16 shards, per-shard WAL):");
println!(" per-op fsync : {:>8.1} k puts/s", per_op);
println!(" group-commit : {:>8.1} k puts/s ({:.1}x)", batch, batch/per_op);
println!("\n=> group-commit batches one fsync per shard for many ops => durable writes scale with the");
println!(" batch (no tables layer — pure storage engine; CUBE's metatag model is the schema).");
}