Don't run full compaction after initial import is over

This commit is contained in:
Roman Zeyde 2018-10-14 10:58:48 +03:00
parent c2563701eb
commit 1dcc8ac575
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

View File

@ -38,18 +38,18 @@ fn run_server(config: &Config) -> Result<()> {
// Perform initial indexing from local blk*.dat block files. // Perform initial indexing from local blk*.dat block files.
let store = DBStore::open(&config.db_path, /*low_memory=*/ config.jsonrpc_import); let store = DBStore::open(&config.db_path, /*low_memory=*/ config.jsonrpc_import);
let index = Index::load(&store, &daemon, &metrics, config.index_batch_size)?; let index = Index::load(&store, &daemon, &metrics, config.index_batch_size)?;
let store = if config.jsonrpc_import { let store = if is_fully_compacted(&store) {
store // initial import and full compaction are over
} else {
if config.jsonrpc_import {
index.update(&store, &signal)?; // slower: uses JSONRPC for fetching blocks index.update(&store, &signal)?; // slower: uses JSONRPC for fetching blocks
full_compaction(store) full_compaction(store)
} else { } else {
// faster, but uses more memory // faster, but uses more memory
if is_fully_compacted(&store) == false {
let store = bulk::index_blk_files(&daemon, config.bulk_index_threads, &metrics, store)?; let store = bulk::index_blk_files(&daemon, config.bulk_index_threads, &metrics, store)?;
let store = full_compaction(store); let store = full_compaction(store);
index.reload(&store); // make sure the block header index is up-to-date index.reload(&store); // make sure the block header index is up-to-date
store store
} else {
store
} }
}.enable_compaction(); // enable auto compactions before starting incremental index updates. }.enable_compaction(); // enable auto compactions before starting incremental index updates.