diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 03029dd5d06e961177691a7428dca30ee175b9a9..cb6d0402f5899c6104bc6f032b18a4b0678c070d 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -384,6 +384,10 @@ allow_profile_lookup_federation_requests = true # Defaults to false #rocksdb_optimize_for_spinning_disks = false +# Enables direct-io to increase database performance. This is enabled by default. Set this option to false if the +# database resides on a filesystem which does not support direct-io. +#rocksdb_direct_io = true + # RocksDB log level. This is not the same as conduwuit's log level. This is the log level for the RocksDB engine/library # which show up in your database folder/path as `LOG` files. Defaults to error. conduwuit will typically log RocksDB errors as normal. #rocksdb_log_level = "error" diff --git a/src/config/mod.rs b/src/config/mod.rs index 315e1fb481695c74df37ee1d18806453af1e5aaf..161aa4b5aac27560bcec31783a2114f337f01da0 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -218,6 +218,8 @@ pub(crate) struct Config { pub(crate) rocksdb_log_time_to_roll: usize, #[serde(default)] pub(crate) rocksdb_optimize_for_spinning_disks: bool, + #[serde(default = "true_fn")] + pub(crate) rocksdb_direct_io: bool, #[serde(default = "default_rocksdb_parallelism_threads")] pub(crate) rocksdb_parallelism_threads: usize, #[serde(default = "default_rocksdb_max_log_files")] @@ -703,6 +705,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { &self.rocksdb_optimize_for_spinning_disks.to_string(), ), #[cfg(feature = "rocksdb")] + ("RocksDB Direct-IO", &self.rocksdb_direct_io.to_string()), + #[cfg(feature = "rocksdb")] ("RocksDB Parallelism Threads", &self.rocksdb_parallelism_threads.to_string()), #[cfg(feature = "rocksdb")] ("RocksDB Compression Algorithm", &self.rocksdb_compression_algo), diff --git a/src/database/rocksdb/opts.rs b/src/database/rocksdb/opts.rs index 6d2308999cb32c89ed70a3df0f7bdb60e4740d26..8e90bec666ebcacaf5187f8b5ddb031acc69193d 100644 --- a/src/database/rocksdb/opts.rs +++ b/src/database/rocksdb/opts.rs @@ -36,8 +36,10 @@ pub(crate) fn db_options(config: &Config, env: &mut Env, row_cache: &Cache, col_ // IO opts.set_manual_wal_flush(true); - opts.set_use_direct_reads(true); - opts.set_use_direct_io_for_flush_and_compaction(true); + if config.rocksdb_direct_io { + opts.set_use_direct_reads(true); + opts.set_use_direct_io_for_flush_and_compaction(true); + } if config.rocksdb_optimize_for_spinning_disks { // speeds up opening DB on hard drives opts.set_skip_checking_sst_file_sizes_on_db_open(true);