-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Get rid of parity-util-mem
dependency
#12658
Comments
Just a note: when do this we should not forget to add back jemalloc to the relevant binary crates (since it is currently included through |
We didn't had jemalloc anywhere enabled in Substrate. It always requires that downstream enabled jemalloc in their bins. |
Looking forward to having this! |
I can pick this up. Some questions:
|
Tracking size of allocated memory given a reference in O(1) time.
It has several issues. The biggest one is probably soundness issue (follow the links from PR) of having two multiple versions of the crate, which prompted to ban duplicates: paritytech/parity-common#363. Because we ban duplicates, this causes many troubles for parachain teams (and previously subxt users as well). Another big issue is how breaking changes cascade (as it's used in many public APIs itself) once we modify one of its dependencies. Rel. paritytech/parity-common#377 (but not only that).
First references, then entirely. I don't think anyone depends on this crate really. Original codes comes from servo. Some of it was extracted for general purpose, but doesn't seem maintained: https://github.com/bholley/malloc_size_of_derive. The tests that were introduced in #4822 can be removed while we remove references. |
So we considered removing the substrate/client/state-db/src/lib.rs Lines 395 to 397 in 4e3a12b
But looks like that is always 0... substrate/client/state-db/src/pruning.rs Lines 348 to 350 in 4e3a12b
I did a double-take, but looks like that's the method being called. So I think that break above is always triggered.
I'm considering if we can just remove substrate/client/state-db/src/pruning.rs Lines 54 to 70 in 4e3a12b
There's a couple nested data structures there, as well as a MetaDb thing. 😱 (edit: just noticed the annotate to ignore the memory of the db)
But anyway, seems like pruning is currently a no-op? If so, we can remove the mem used info and don't have to bother with the estimations. Not sure if the constrained mode is ever set anyway; looks like the mode ultimately comes from a config. cc @arkpar |
Memory constraint for state-db is currently not used. As in not exposed to the CLI options. There was not much demand for is, as having predictable pruning history size is preferable. I guess we can remove it. |
Current SummarysubstrateRemoved the dep from
so we will need to remove the dep from polkadot (please help)Removing the dep from Then I ran into this Removing all references to that thing results in a million errors, because Also, I have a question about whether we need https://github.com/paritytech/polkadot/blob/master/primitives/src/v2/mod.rs#L1765-L1769 Also 2: Note that I had to remove some parity-commonRemoved the dep here easily enough. trie (please help)Started removing the dep from |
You will need to implement some new trait, maybe directly this ResidentSize trait. However, for now it could probably be done local to the trait declaration? |
TBH, I feel like we should get rid of memory-lru usage for runtime-api cache. Instead use a regular lru cache with a reasonable enough number of entries we can keep in memory for each type. |
No, we don't. In fact this type can be removed completely along with old runtime api, but out of scope of this PR. |
What do you mean? Why can just remove it? IIRC the |
@ordian Okay, just raised the PR. I was seeing the code for the first time and it looked like the mem tracking was all over it. But yeah, in the end it was unused. Should I also bump the versions etc. in that PR? |
To do this we would need to provide size estimates for all the types, right? Doing that seems non-trivial, as some of the types are e.g. Vecs of Vecs, or even more complex. (That rhymed!)
This makes sense to me. I just need help picking the number of entries, then I'll be good to go. Maybe |
I'd prefer different sizes. For example,
|
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-release-analysis-v0-9-36/1529/1 |
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
NonCanonicalOverlay
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.
The text was updated successfully, but these errors were encountered: