mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 17:24:21 +01:00
stress: Add --vfs <io-method> command line option
...unlocks io_uring stress runs.
This commit is contained in:
@@ -476,9 +476,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
tempfile.path().to_string_lossy().to_string()
|
||||
};
|
||||
|
||||
let vfs_option = opts.vfs.clone();
|
||||
|
||||
for thread in 0..opts.nr_threads {
|
||||
let db_file = db_file.clone();
|
||||
let db = Arc::new(Mutex::new(Builder::new_local(&db_file).build().await?));
|
||||
let mut builder = Builder::new_local(&db_file);
|
||||
if let Some(ref vfs) = vfs_option {
|
||||
builder = builder.with_io(vfs.clone());
|
||||
}
|
||||
let db = Arc::new(Mutex::new(builder.build().await?));
|
||||
let plan = plan.clone();
|
||||
let conn = db.lock().await.connect()?;
|
||||
|
||||
@@ -507,6 +513,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
|
||||
let nr_iterations = opts.nr_iterations;
|
||||
let db = db.clone();
|
||||
let vfs_for_task = vfs_option.clone();
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
let mut conn = db.lock().await.connect()?;
|
||||
@@ -518,7 +525,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
}
|
||||
// Reopen the database
|
||||
let mut db_guard = db.lock().await;
|
||||
*db_guard = Builder::new_local(&db_file).build().await?;
|
||||
let mut builder = Builder::new_local(&db_file);
|
||||
if let Some(ref vfs) = vfs_for_task {
|
||||
builder = builder.with_io(vfs.clone());
|
||||
}
|
||||
*db_guard = builder.build().await?;
|
||||
conn = db_guard.connect()?;
|
||||
} else if gen_bool(0.01) {
|
||||
// Reconnect to the database
|
||||
|
||||
@@ -55,4 +55,11 @@ pub struct Opts {
|
||||
/// Database file
|
||||
#[clap(short = 'd', long, help = "database file")]
|
||||
pub db_file: Option<String>,
|
||||
|
||||
/// Select VFS
|
||||
#[clap(
|
||||
long,
|
||||
help = "Select VFS. options are io_uring (if feature enabled), memory, and syscall"
|
||||
)]
|
||||
pub vfs: Option<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user