paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.92k stars 707 forks source link

Update database benchmarks to take trie cache into account #6131

Open athei opened 1 month ago

athei commented 1 month ago

As of right now the weight for database access is hard coded to 25us and 100us for read and write respectively. Those numbers are way too high given that we have a trie cache now.

We should write a benchmark that benchmarks storage access with a warm cache. Meaning that every access in the benchmark hits the cache. This is okay to assume as we will require the cache to be larger than the state size.

The results of that benchmark can be used for chains where we require collators to set a large --trie-cache-size. For example, AssetHub.

@ggwpez Do we have a storage access benchmark already in the codebase somewhere?

ggwpez commented 1 month ago

Sorry did not see the ping, the code is here:
https://github.com/paritytech/polkadot-sdk/blob/f8e3bdad3df8eceba0a7d0e5e2f90f32a9be1bc8/substrate/utils/frame/benchmarking-cli/src/storage/read.rs#L51-L52

You can use it from the polkadot or polkadot-omni-node binary:
polkadot benchmark storage --state-version 1 -d ~/.local/share/polkadot or same with polkadot-omni-node, but then it also needs a --chain spec.