Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate DB weights for top and child keys #387

Open
ggwpez opened this issue Aug 16, 2022 · 4 comments
Open

Separate DB weights for top and child keys #387

ggwpez opened this issue Aug 16, 2022 · 4 comments

Comments

@ggwpez
Copy link
Member

ggwpez commented Aug 16, 2022

paritytech/substrate#12021 allows to also benchmark child storage keys.
We can now then think about how to generate custom weights for both and combine them, instead of directly combining them.
One use-case is that some chains may have much more child than top keys or vice-versa.

There are multiple approaches:

  • Extend RuntimeDbWeight struct (Will collide with WeightsV2)
  • Modify the template to contain three RuntimeDbWeight (top, child and combined)
  • Combine them in the CLI with a ratio option, like --child-key-weight-ratio PERCENT.
@bkchr
Copy link
Member

bkchr commented Aug 17, 2022

Why would you need to separate them? Is the db weight calculated based on the maximum depth of the main trie?

@ggwpez
Copy link
Member Author

ggwpez commented Aug 17, 2022

This would only help in case that the developer knows that child keys will be read with higher or lower probability than top keys.
The dev could then set --child-key-weight-ratio to 80% or whatever, to indicate that a random read/write has a 80% chance of being a child key.

So it's not strictly needed but more of an optimization for power users.

@bkchr
Copy link
Member

bkchr commented Aug 17, 2022

Yeah I got this. I just don't know how this influences the weight calculation.

@ggwpez
Copy link
Member Author

ggwpez commented Aug 17, 2022

It does not influence the formula with which it is calculated, but how granular the output is.
Currently we throw all collected time samples into one bucket and then average.
The new version would have one top-, and one child-bucket to collect the results.
The developer could then compose the results from these two weights into a final weight.
I am not sure how this would best be exposed to the devs, hence this issue.

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
* get Substrate dependencies from crates.io

* removing unused dependencies

* cargo fmt --all

* remove commented dependencies

* remove commented dependencies again

* try to fix compilation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants