You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
/// Internal trait similar to `heapsize` but using
/// a simply estimation.
///
/// This should not be made public, it is implementation
/// detail trait. If it need to become public please
/// consider using `malloc_size_of`.
traitEstimateSize{
/// Return a size estimation of additional size needed
/// to cache this struct (in bytes).
fnestimate_size(&self) -> usize;
}
or more brittle
For each collection, you can estimate size by .capacity() * mem::size_of::<T>().
The only problematic case is nested data-structures, like pinned_insertions: HashMap<BlockHash, (Vec, u32)>,. Here the value size is variable.
A workaround could be adding a struct alongside NonCanonicalOverlay that is tracking size on every insertion/deletion to its field pinned_insertions or simply assuming max size.
Originally reported in #12657 (comment)
Steps:
At the moment it seems there are two
substrate/client/state-db/src/lib.rs
Lines 500 to 506 in cbb48e5
substrate/client/db/src/storage_cache.rs
Lines 62 to 72 in 20b5aac
.capacity() * mem::size_of::<T>().A workaround could be adding a struct alongside
NonCanonicalOverlaythat is tracking size on every insertion/deletion to its fieldpinned_insertionsor simply assuming max size.Once the usage is replaced, to get rid of the dependency completely, we'd need to remove it from a number of crates in https://github.com/paritytech/trie and https://github.com/paritytech/parity-common.