Skip to content

Commit ece6e73

Browse files
committed
enable compaction during initial sync flag
1 parent bfc323a commit ece6e73

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ pub struct Config {
4444
/// Tx cache size in megabytes
4545
pub tx_cache_size: usize,
4646

47+
/// Enable compaction during initial sync
48+
///
49+
/// By default compaction is off until initial sync is finished for performance reasons,
50+
/// however, this requires much more disk space.
51+
pub initial_sync_compaction: bool,
52+
4753
#[cfg(feature = "liquid")]
4854
pub parent_network: BNetwork,
4955
#[cfg(feature = "liquid")]
@@ -199,6 +205,10 @@ impl Config {
199205
.long("tx-cache-size")
200206
.help("The amount of MB for a in-memory cache for transactions.")
201207
.default_value("1000")
208+
).arg(
209+
Arg::with_name("initial_sync_compaction")
210+
.long("initial-sync-compaction")
211+
.help("Perform compaction during initial sync (slower but less disk space required)")
202212
);
203213

204214
#[cfg(unix)]
@@ -412,6 +422,7 @@ impl Config {
412422
cors: m.value_of("cors").map(|s| s.to_string()),
413423
precache_scripts: m.value_of("precache_scripts").map(|s| s.to_string()),
414424
tx_cache_size: value_t_or_exit!(m, "tx_cache_size", usize),
425+
initial_sync_compaction: m.is_present("initial_sync_compaction"),
415426

416427
#[cfg(feature = "liquid")]
417428
parent_network,

src/new_index/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl DB {
9090
db_opts.set_compression_type(rocksdb::DBCompressionType::Snappy);
9191
db_opts.set_target_file_size_base(1_073_741_824);
9292
db_opts.set_write_buffer_size(256 << 20);
93-
db_opts.set_disable_auto_compactions(true); // for initial bulk load
93+
db_opts.set_disable_auto_compactions(!config.initial_sync_compaction); // for initial bulk load
9494

9595
// db_opts.set_advise_random_on_open(???);
9696
db_opts.set_compaction_readahead_size(1 << 20);

0 commit comments

Comments
 (0)