Skip to content

Commit

Permalink
flush data to the permanent store in larger portions
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-babichenko committed Sep 24, 2020
1 parent 9322705 commit aceb476
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions jormungandr/src/blockchain/storage.rs
Expand Up @@ -11,6 +11,8 @@ use thiserror::Error;
use std::convert::identity;
use std::path::Path;

const PERMANENT_STORE_FLUSH_GAP: u32 = 1024;

#[derive(Debug, Error)]
pub enum Error {
#[error("block not found")]
Expand Down Expand Up @@ -282,8 +284,13 @@ impl Storage {
let to_block_info = self
.storage
.get_nth_ancestor(main_branch_tip, threshold_depth)?;
self.storage
.flush_to_permanent_store(to_block_info.id().as_ref())?;

// Permanent store extension is better to do in large portions of data
// at once. This puts less strain on the paging subsystem.
if threshold_length % PERMANENT_STORE_FLUSH_GAP == 0 {
self.storage
.flush_to_permanent_store(to_block_info.id().as_ref())?;
}

Ok(())
}
Expand Down

0 comments on commit aceb476

Please sign in to comment.