Skip to content

Commit

Permalink
feat: make parents cache size configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jun 17, 2020
1 parent 5feb0d0 commit 2673271
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions storage-proofs/core/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Settings {
pub use_gpu_tree_builder: bool,
pub max_gpu_tree_batch_size: u32,
pub rows_to_discard: u32,
pub sdr_parents_cache_size: u32,
}

impl Default for Settings {
Expand All @@ -35,6 +36,7 @@ impl Default for Settings {
use_gpu_tree_builder: false,
max_gpu_tree_batch_size: 700_000,
rows_to_discard: 2,
sdr_parents_cache_size: 2048,
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions storage-proofs/porep/src/stacked/vanilla/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use storage_proofs_core::{
error::Result,
hasher::Hasher,
parameter_cache::ParameterSetMetadata,
settings,
util::NODE_SIZE,
};

Expand Down Expand Up @@ -132,9 +133,9 @@ where
/// Returns a reference to the parent cache.
pub fn parent_cache(&self) -> Result<ParentCache> {
// Number of nodes to be cached in memory
const DEFAULT_CACHE_SIZE: u32 = 2048;
let default_cache_size = settings::SETTINGS.lock().unwrap().sdr_parents_cache_size;
let cache_entries = self.size() as u32;
let cache_size = cache_entries.min(DEFAULT_CACHE_SIZE);
let cache_size = cache_entries.min(default_cache_size);

info!("using parent_cache[{} / {}]", cache_size, cache_entries);

Expand Down

0 comments on commit 2673271

Please sign in to comment.