cache manager and clearing tracing cache (#1769)

* removed configure_cache method

* generic cache_manager struct

* fixed #1743, tracing caches are cleared

* removed deadlocks in garbage_collect, implemented HeapSizeOf for traces

* trace cache config

* fixed carbage typo
This commit is contained in:
Marek Kotewicz
2016-07-31 00:19:27 +02:00
committed by Gav Wood
parent b29329c3c5
commit bcf8cd6dc0
9 changed files with 193 additions and 92 deletions

View File

@@ -20,6 +20,7 @@ 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_TRACE_CACHE_SIZE: u32 = 20;
/// Configuration for application cache sizes.
/// All values are represented in MB.
@@ -34,6 +35,8 @@ pub struct CacheConfig {
blockchain: u32,
/// Size of transaction queue cache.
queue: u32,
/// Size of traces cache.
traces: u32,
}
impl Default for CacheConfig {
@@ -49,6 +52,7 @@ impl CacheConfig {
db: total * 7 / 8,
blockchain: total / 8,
queue: DEFAULT_BLOCK_QUEUE_SIZE_LIMIT_MB,
traces: DEFAULT_TRACE_CACHE_SIZE,
}
}
@@ -58,6 +62,7 @@ impl CacheConfig {
db: db,
blockchain: blockchain,
queue: queue,
traces: DEFAULT_TRACE_CACHE_SIZE,
}
}
@@ -80,6 +85,11 @@ impl CacheConfig {
pub fn blockchain(&self) -> u32 {
max(self.blockchain, MIN_BC_CACHE_MB)
}
/// Size of the traces cache.
pub fn traces(&self) -> u32 {
self.traces
}
}
#[cfg(test)]

View File

@@ -212,6 +212,10 @@ pub fn to_client_config(
client_config.db_cache_size = Some(cache_config.db_state_cache_size() as usize);
// db queue cache size, in bytes
client_config.queue.max_mem_use = cache_config.queue() as usize * mb;
// in bytes
client_config.tracing.max_cache_size = cache_config.traces() as usize * mb;
// in bytes
client_config.tracing.pref_cache_size = cache_config.traces() as usize * 3 / 4 * mb;
client_config.mode = mode;
client_config.tracing.enabled = tracing;