From 661101c9ae751b09b97119a1f8071871f1b2a252 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 15 Jul 2021 13:29:08 +0200 Subject: [PATCH 1/2] add sled cache_capacity back --- Cargo.toml | 4 ++-- src/database.rs | 6 ++++++ src/database/abstraction/sled.rs | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 537813f1..0f40ab78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,14 +77,14 @@ lru-cache = "0.1.2" rusqlite = { version = "0.25.3", optional = true, features = ["bundled"] } parking_lot = { version = "0.11.1", optional = true } crossbeam = { version = "0.8.1", optional = true } -num_cpus = { version = "1.13.0", optional = true } +num_cpus = "1.13.0" [features] default = ["conduit_bin", "backend_sqlite"] backend_sled = ["sled"] backend_rocksdb = ["rocksdb"] backend_sqlite = ["sqlite"] -sqlite = ["rusqlite", "parking_lot", "crossbeam", "num_cpus", "tokio/signal"] +sqlite = ["rusqlite", "parking_lot", "crossbeam", "tokio/signal"] conduit_bin = [] # TODO: add rocket to this when it is optional [[bin]] diff --git a/src/database.rs b/src/database.rs index c39f0fbd..85beee80 100644 --- a/src/database.rs +++ b/src/database.rs @@ -45,6 +45,8 @@ pub struct Config { database_path: String, #[serde(default = "default_db_cache_capacity_mb")] db_cache_capacity_mb: f64, + #[serde(default = "default_sled_cache_capacity_bytes")] + sled_cache_capacity_bytes: u64, #[serde(default = "default_sqlite_read_pool_size")] sqlite_read_pool_size: usize, #[serde(default = "true_fn")] @@ -109,6 +111,10 @@ fn default_db_cache_capacity_mb() -> f64 { 200.0 } +fn default_sled_cache_capacity_bytes() -> u64 { + 1024 * 1024 * 1024 +} + fn default_sqlite_read_pool_size() -> usize { num_cpus::get().max(1) } diff --git a/src/database/abstraction/sled.rs b/src/database/abstraction/sled.rs index e58184df..1aa631fe 100644 --- a/src/database/abstraction/sled.rs +++ b/src/database/abstraction/sled.rs @@ -14,7 +14,7 @@ impl DatabaseEngine for Engine { Ok(Arc::new(Engine( sled::Config::default() .path(&config.database_path) - .cache_capacity((config.db_cache_capacity_mb * 1024 * 1024) as u64) + .cache_capacity(config.sled_cache_capacity_bytes) .use_compression(true) .open()?, ))) From d76e95e8fc9d39fcab36e43fcd6f971c556782d8 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Thu, 15 Jul 2021 13:47:21 +0200 Subject: [PATCH 2/2] use existing db cache size --- src/database.rs | 6 ------ src/database/abstraction/sled.rs | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/database.rs b/src/database.rs index 85beee80..c39f0fbd 100644 --- a/src/database.rs +++ b/src/database.rs @@ -45,8 +45,6 @@ pub struct Config { database_path: String, #[serde(default = "default_db_cache_capacity_mb")] db_cache_capacity_mb: f64, - #[serde(default = "default_sled_cache_capacity_bytes")] - sled_cache_capacity_bytes: u64, #[serde(default = "default_sqlite_read_pool_size")] sqlite_read_pool_size: usize, #[serde(default = "true_fn")] @@ -111,10 +109,6 @@ fn default_db_cache_capacity_mb() -> f64 { 200.0 } -fn default_sled_cache_capacity_bytes() -> u64 { - 1024 * 1024 * 1024 -} - fn default_sqlite_read_pool_size() -> usize { num_cpus::get().max(1) } diff --git a/src/database/abstraction/sled.rs b/src/database/abstraction/sled.rs index 1aa631fe..12e02751 100644 --- a/src/database/abstraction/sled.rs +++ b/src/database/abstraction/sled.rs @@ -14,7 +14,7 @@ impl DatabaseEngine for Engine { Ok(Arc::new(Engine( sled::Config::default() .path(&config.database_path) - .cache_capacity(config.sled_cache_capacity_bytes) + .cache_capacity((config.db_cache_capacity_mb * 1024.0 * 1024.0) as u64) .use_compression(true) .open()?, )))