Skip to content

Commit

Permalink
enable compaction during initial sync flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Sep 20, 2024
1 parent bfc323a commit 5e695a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/new_index/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5e695a6

Please sign in to comment.