From cee0b647edf9c789daebb87b4e9878f129b38de5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 7 Apr 2025 23:52:39 +0200 Subject: disable rocksdb WAL --- src/cache.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index d6fa818..b9b19c2 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -19,6 +19,7 @@ pub enum Cache { }, Rocksdb { db: rocksdb::DBWithThreadMode, + wopts: rocksdb::WriteOptions, }, } const T_DOWNLOAD: redb::TableDefinition<&str, &[u8]> = redb::TableDefinition::new("dl"); @@ -49,11 +50,13 @@ impl Cache { pub fn new_rocksdb(path: &Path) -> Result { info!("opening rocksdb..."); let mut opts = rocksdb::Options::default(); + let mut wopts = rocksdb::WriteOptions::default(); opts.increase_parallelism(8); opts.create_if_missing(true); + wopts.disable_wal(true); let db = rocksdb::DBWithThreadMode::open(&opts, path)?; info!("done"); - Ok(Self::Rocksdb { db }) + Ok(Self::Rocksdb { db, wopts }) } pub async fn transfer_entries(&self, other: &Cache) -> Result<()> { @@ -118,7 +121,7 @@ impl Cache { Ok(None) } } - Cache::Rocksdb { db } => Ok(db.get(path)?), + Cache::Rocksdb { db, .. } => Ok(db.get(path)?), } } pub async fn insert(&self, path: &str, data: &[u8]) -> Result<()> { @@ -144,8 +147,8 @@ impl Cache { txn.commit()?; Ok(()) } - Cache::Rocksdb { db } => { - db.put(path, data)?; + Cache::Rocksdb { db, wopts } => { + db.put_opt(path, data, &wopts)?; Ok(()) } } -- cgit v1.2.3-70-g09d2