-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
204 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "lsm" | ||
version = "0.4.1" | ||
version = "0.5.0-dev" | ||
authors = ["Kai Mast <[email protected]>"] | ||
edition = "2024" | ||
repository = "https://github.com/kaimast/lsm-rs" | ||
|
@@ -26,7 +26,7 @@ tokio-condvar = { version="0.3", features=["parking_lot"] } | |
tokio-uring = { version="0.5", optional=true } | ||
bloomfilter = { version="3", optional=true } | ||
monoio = { version="0.2", optional=true, features=["sync"] } | ||
kioto-uring-executor = { version="0.2", optional=true } | ||
kioto-uring-executor = { version="0.3.0-dev", optional=true } | ||
bitvec = { version="1", optional=true } | ||
|
||
[dependencies.tokio] | ||
|
@@ -41,7 +41,7 @@ tempfile = "3" | |
tracing-tracy = "0.11" | ||
tokio = { version="1", default-features=false, features=["rt-multi-thread"] } | ||
tracing-subscriber = { version="0.3", default-features=false } | ||
rand = "0.8.5" | ||
rand = "0.8" | ||
|
||
[lib] | ||
path = "src/lib.rs" | ||
|
@@ -68,4 +68,7 @@ name = "lsm-benchmark" | |
path = "benchmarks/async.rs" | ||
|
||
[workspace] | ||
members = ["sync"] | ||
members = ["sync", "bigtest"] | ||
|
||
[patch.crates-io] | ||
kioto-uring-executor = { git = "https://github.com/kaimast/kioto-uring-executor" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "lsm-bigtest" | ||
version = "0.5.0-dev" | ||
edition = "2024" | ||
authors = ["Kai Mast <[email protected]>"] | ||
license = "MIT" | ||
description = "Runs a longer test with lots of data" | ||
readme = "../README.md" | ||
|
||
[dependencies] | ||
kioto-uring-executor = "0.3.0-dev" | ||
clap = { version="4", features=["derive"] } | ||
env_logger = "0.11" | ||
tempfile = "3" | ||
rand = "0.8" | ||
|
||
[dependencies.lsm] | ||
path = ".." | ||
features = ["tokio-uring"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
use std::sync::Arc; | ||
|
||
use clap::Parser; | ||
use rand::Rng; | ||
|
||
use lsm::{Database, Params, StartMode}; | ||
|
||
#[derive(Parser)] | ||
struct Args { | ||
#[clap(long, short = 'n', default_value_t = 100_000)] | ||
#[clap(help = "The number of insertions per thread")] | ||
num_insertions: usize, | ||
|
||
#[clap(long, short = 't', default_value_t = 10)] | ||
num_threads: usize, | ||
|
||
#[clap(long, default_value_t = 1_000_000)] | ||
key_range: usize, | ||
|
||
#[clap(long, default_value_t = 1024)] | ||
entry_size: usize, | ||
|
||
#[clap(long, default_value = "/tmp")] | ||
#[clap( | ||
help = "Where to create the temporary working directory? Note, this is the parent directoy of the directory not the directoy itself. | ||
It is recommended to use a tmpfs to not wear out a physical disk" | ||
)] | ||
workdir_location: String, | ||
} | ||
|
||
#[kioto_uring_executor::main] | ||
async fn main() { | ||
env_logger::init(); | ||
|
||
let args = Args::parse(); | ||
|
||
if args.num_insertions == 0 { | ||
panic!("Need to insert at least one entry"); | ||
} | ||
|
||
if args.key_range == 0 { | ||
panic!("Key range cannot be zero"); | ||
} | ||
|
||
println!("Creating working directory and empty database"); | ||
let tmp_dir = tempfile::Builder::new() | ||
.prefix("lsm-bigest-") | ||
.tempdir_in(args.workdir_location) | ||
.expect("Failed to create working directory"); | ||
|
||
let mut db_path = tmp_dir.path().to_path_buf(); | ||
db_path.push("storage.lsm"); | ||
|
||
let params = Params { | ||
db_path, | ||
..Default::default() | ||
}; | ||
|
||
let database = Arc::new( | ||
Database::new_with_params(StartMode::CreateOrOverride, params) | ||
.await | ||
.expect("Failed to create database instance"), | ||
); | ||
|
||
println!( | ||
"Inserting a total of {} entries of size {} across {} threads", | ||
args.num_insertions * args.num_threads, | ||
args.entry_size, | ||
args.num_threads | ||
); | ||
|
||
let tasks: Vec<_> = (1..=args.num_threads) | ||
.map(|idx| { | ||
let database = database.clone(); | ||
kioto_uring_executor::spawn_with(move || { | ||
let mut rng = rand::thread_rng(); | ||
Box::pin(async move { | ||
for count in 1..=args.num_insertions { | ||
let key_idx = rng.gen_range(0..args.key_range); | ||
let key = format!("key{key_idx}").as_bytes().to_vec(); | ||
|
||
let mut value = vec![0; args.entry_size]; | ||
rng.fill(value.as_mut_slice()); | ||
|
||
database.put(key, value).await.expect("Insert failed"); | ||
|
||
if count % 10_000 == 0 { | ||
println!( | ||
"Thread #{idx} inserted {count} entries so far ({}%)", | ||
(count as f64) * 100.0 / (args.num_insertions as f64) | ||
); | ||
} | ||
} | ||
println!("Thread #{idx} is done"); | ||
}) | ||
}) | ||
}) | ||
.collect(); | ||
|
||
for task in tasks { | ||
task.join().await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.