substrate icon indicating copy to clipboard operation
substrate copied to clipboard

child trie optimization

Open cheme opened this issue 6 years ago • 0 comments

A few optimization that may require changing 'trie' crates.

  • default_child_trie_root function is mainly use to check if a trie gets empty.

This value is calculated every time but always returns the same value.

Function defauld_chid_trie_root should be able to return a constant value.

I should be a constant (ideally calculated at compilation like proposed in paritytech/polkadot-sdk#372 from a empty trie encoded value).

This issue may also involve changing some components in https://github.com/paritytech/trie.

  • related to paritytech/substrate#2209 KeySpacedDB

KeySpacedDB currently prepened keyspace to the prefix and then memorydb keyfunction prepend the prefix to the key. There is a new vec in each steps, reasonably a single instantiation should be done.

An approach could be to change key function, triedb and triedbmut to be aware of keyspace like in https://github.com/paritytech/trie/compare/master...cheme:kf_change (code from paritytech/substrate#2209 also get way simplier).

cheme avatar May 31 '19 08:05 cheme