Remove calls to heapsize (#10432)

* update memorydb trait
* use malloc_size_of instead of heapsize_of
* use jemalloc as default allocator for parity client.
This commit is contained in:
cheme
2019-06-19 13:54:05 +02:00
committed by GitHub
parent 859a41308c
commit 6fc5014b4d
84 changed files with 926 additions and 1074 deletions

View File

@@ -18,10 +18,10 @@
//! crate.
// TODO: push changes upstream in a clean way.
extern crate heapsize;
extern crate parity_util_mem;
extern crate lru_cache;
use heapsize::HeapSizeOf;
use parity_util_mem::{MallocSizeOf, MallocSizeOfExt};
use lru_cache::LruCache;
use std::hash::Hash;
@@ -29,18 +29,18 @@ use std::hash::Hash;
const INITIAL_CAPACITY: usize = 4;
/// An LRU-cache which operates on memory used.
pub struct MemoryLruCache<K: Eq + Hash, V: HeapSizeOf> {
pub struct MemoryLruCache<K: Eq + Hash, V> {
inner: LruCache<K, V>,
cur_size: usize,
max_size: usize,
}
// amount of memory used when the item will be put on the heap.
fn heap_size_of<T: HeapSizeOf>(val: &T) -> usize {
::std::mem::size_of::<T>() + val.heap_size_of_children()
fn heap_size_of<T: MallocSizeOf>(val: &T) -> usize {
::std::mem::size_of::<T>() + val.malloc_size_of()
}
impl<K: Eq + Hash, V: HeapSizeOf> MemoryLruCache<K, V> {
impl<K: Eq + Hash, V: MallocSizeOf> MemoryLruCache<K, V> {
/// Create a new cache with a maximum size in bytes.
pub fn new(max_size: usize) -> Self {
MemoryLruCache {