This repository was archived by the owner on Nov 6, 2020. It is now read-only.
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
StateDB overhaul #9427
Closed
Description
Our current StateDB implementation is not fully optimized:
- For the first time writing a value not in a checkpoint, or when reverting a checkpoint, all values in the account entry needs to be swapped.
- Sometimes we call
clone_dirty
on an account to clone all dirty values, but we actually only need a few. - When fetching a checkpoint storage value, in the case where the account entry is not in the checkpoint, we would need to cascade up towards the checkpoint chain. This is the reverse of the issue we face in AccountDb is inefficient paritytech/substrate#480
To fix this, here're some ideas we can do:
- Remove indirection of storage values in account entry. Keep one change tree for storage entries, and keep another for other account values.
- Keep original account value caches (the value of the account since last state commit) as normal hash maps.
- Keep account value changes as complete
im::HashMap
(meaning, if anything is not in the hash trie, then we're sure the value has not changed since last commit). This makes creating/reverting checkpoints really cheap.