diff --git a/src/config.rs b/src/config.rs index 86d8f2bc3..762aac596 100644 --- a/src/config.rs +++ b/src/config.rs @@ -44,6 +44,12 @@ pub struct Config { /// Tx cache size in megabytes pub tx_cache_size: usize, + /// Enable compaction during initial sync + /// + /// By default compaction is off until initial sync is finished for performance reasons, + /// however, this requires much more disk space. + pub initial_sync_compaction: bool, + #[cfg(feature = "liquid")] pub parent_network: BNetwork, #[cfg(feature = "liquid")] @@ -412,6 +418,7 @@ impl Config { cors: m.value_of("cors").map(|s| s.to_string()), precache_scripts: m.value_of("precache_scripts").map(|s| s.to_string()), tx_cache_size: value_t_or_exit!(m, "tx_cache_size", usize), + initial_sync_compaction: m.is_present("initial_sync_compaction"), #[cfg(feature = "liquid")] parent_network, diff --git a/src/new_index/db.rs b/src/new_index/db.rs index f68da233c..77e1a66d4 100644 --- a/src/new_index/db.rs +++ b/src/new_index/db.rs @@ -90,7 +90,7 @@ impl DB { db_opts.set_compression_type(rocksdb::DBCompressionType::Snappy); db_opts.set_target_file_size_base(1_073_741_824); db_opts.set_write_buffer_size(256 << 20); - db_opts.set_disable_auto_compactions(true); // for initial bulk load + db_opts.set_disable_auto_compactions(!config.initial_sync_compaction); // for initial bulk load // db_opts.set_advise_random_on_open(???); db_opts.set_compaction_readahead_size(1 << 20);