This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Get rid of parity-util-mem
dependency #12658
Closed
Description
Originally reported in #12657 (comment)
Steps:
- Identify all the usage: https://cs.github.com/paritytech/substrate?q=malloc_size
At the moment it seems there are two
- substrate (informational only):
substrate/client/state-db/src/lib.rs
Lines 500 to 506 in cbb48e5
- polkadot: https://github.com/paritytech/polkadot/blob/a70d12ae1da07167bb33c5fce6f6f4f5ab511fff/node/core/runtime-api/src/cache.rs#L54-L58
- Replace the usage by an estimation. It could be something like
substrate/client/db/src/storage_cache.rs
Lines 62 to 72 in 20b5aac
- 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 alongsideNonCanonicalOverlay
that is tracking size on every insertion/deletion to its fieldpinned_insertions
or 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
done