stress: Add --vfs <io-method> command line option

...unlocks io_uring stress runs.
This commit is contained in:
Pekka Enberg
2025-09-04 19:15:01 +03:00
parent ed6d5fd3d7
commit f61e26eeb1
2 changed files with 20 additions and 2 deletions

View File

@@ -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

View File

@@ -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>,
}