Memory usage optimization (#5526)

This commit is contained in:
Arkadiy Paronyan
2017-05-02 11:40:03 +02:00
committed by Gav Wood
parent c39da9643e
commit da2f684f18
6 changed files with 18 additions and 16 deletions

View File

@@ -19,7 +19,7 @@ use std::cmp::max;
const MIN_BC_CACHE_MB: u32 = 4;
const MIN_DB_CACHE_MB: u32 = 2;
const MIN_BLOCK_QUEUE_SIZE_LIMIT_MB: u32 = 16;
const DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB: u32 = 50;
const DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB: u32 = 40;
const DEFAULT_TRACE_CACHE_SIZE: u32 = 20;
const DEFAULT_STATE_CACHE_SIZE: u32 = 25;
@@ -41,7 +41,7 @@ pub struct CacheConfig {
impl Default for CacheConfig {
fn default() -> Self {
CacheConfig::new(64, 8, DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB, DEFAULT_STATE_CACHE_SIZE)
CacheConfig::new(32, 8, DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB, DEFAULT_STATE_CACHE_SIZE)
}
}
@@ -113,7 +113,7 @@ mod tests {
let config = CacheConfig::new_with_total_cache_size(200);
assert_eq!(config.db, 140);
assert_eq!(config.blockchain(), 20);
assert_eq!(config.queue(), 50);
assert_eq!(config.queue(), 40);
assert_eq!(config.state(), 30);
assert_eq!(config.jump_tables(), 10);
}
@@ -129,6 +129,6 @@ mod tests {
#[test]
fn test_cache_config_default() {
assert_eq!(CacheConfig::default(),
CacheConfig::new(64, 8, super::DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB, super::DEFAULT_STATE_CACHE_SIZE));
CacheConfig::new(32, 8, super::DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB, super::DEFAULT_STATE_CACHE_SIZE));
}
}

View File

@@ -294,13 +294,13 @@ usage! {
or |c: &Config| otry!(c.footprint).pruning.clone(),
flag_pruning_history: u64 = 64u64,
or |c: &Config| otry!(c.footprint).pruning_history.clone(),
flag_pruning_memory: usize = 75usize,
flag_pruning_memory: usize = 32usize,
or |c: &Config| otry!(c.footprint).pruning_memory.clone(),
flag_cache_size_db: u32 = 64u32,
flag_cache_size_db: u32 = 32u32,
or |c: &Config| otry!(c.footprint).cache_size_db.clone(),
flag_cache_size_blocks: u32 = 8u32,
or |c: &Config| otry!(c.footprint).cache_size_blocks.clone(),
flag_cache_size_queue: u32 = 50u32,
flag_cache_size_queue: u32 = 40u32,
or |c: &Config| otry!(c.footprint).cache_size_queue.clone(),
flag_cache_size_state: u32 = 25u32,
or |c: &Config| otry!(c.footprint).cache_size_state.clone(),

View File

@@ -1124,7 +1124,7 @@ mod tests {
format: Default::default(),
pruning: Default::default(),
pruning_history: 64,
pruning_memory: 75,
pruning_memory: 32,
compaction: Default::default(),
wal: true,
tracing: Default::default(),
@@ -1147,7 +1147,7 @@ mod tests {
file_path: Some("blockchain.json".into()),
pruning: Default::default(),
pruning_history: 64,
pruning_memory: 75,
pruning_memory: 32,
format: Default::default(),
compaction: Default::default(),
wal: true,
@@ -1170,7 +1170,7 @@ mod tests {
file_path: Some("state.json".into()),
pruning: Default::default(),
pruning_history: 64,
pruning_memory: 75,
pruning_memory: 32,
format: Default::default(),
compaction: Default::default(),
wal: true,
@@ -1195,7 +1195,7 @@ mod tests {
file_path: Some("blockchain.json".into()),
pruning: Default::default(),
pruning_history: 64,
pruning_memory: 75,
pruning_memory: 32,
format: Some(DataFormat::Hex),
compaction: Default::default(),
wal: true,
@@ -1231,7 +1231,7 @@ mod tests {
spec: Default::default(),
pruning: Default::default(),
pruning_history: 64,
pruning_memory: 75,
pruning_memory: 32,
daemon: None,
logger_config: Default::default(),
miner_options: Default::default(),