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

Benchmarking #2

Closed
4 tasks done
schronck opened this issue Aug 1, 2022 · 3 comments · Fixed by #3
Closed
4 tasks done

Benchmarking #2

schronck opened this issue Aug 1, 2022 · 3 comments · Fixed by #3
Assignees

Comments

@schronck
Copy link
Contributor

schronck commented Aug 1, 2022

Description

We should research the benchmarking features of Substrate and use the weights generated by the benchmarking system in the pallets instead of some hardcoded values.

Solution

  • do some research on weights and benchmarking
  • write benchmarks for the template and guild pallets
  • use a weight template
  • use the weights from the benchmark output instead of hardcoded values
@schronck schronck self-assigned this Aug 1, 2022
@PopcornPaws
Copy link
Contributor

Open a PR to main and let's discuss the results.

@schronck schronck mentioned this issue Aug 8, 2022
@gyozosz
Copy link
Contributor

gyozosz commented Aug 9, 2022

Some notes on weight

  • One unit of weight is supposed to represent one picosecond of execution time on reference hardware
  • Setting the reference hardware is a trade-off between performance and the cost of joining to the chain as a validator
  • Weights should be calculated by benchmarking the reference hardware
  • Substrate's benchmarking assumes linear correlation between the inputs and the execution time of the call so if any calls perform superlinearly then it should not provide a good estimate
  • Weights are used to pace the block creation time to be close to the target (6 seconds by default but only 2 seconds are allocated for performing extrinsic calls)
  • They can be used to manage the time it takes to validate a block
  • Provided weights should represent the worst case scenario on expected hardware
  • Transaction fees are based on weights but in case of cheaper execution excess fees are returned
  • The blockchain is able to calculate how many transactions or system level calls it can execute within a certain period of time based on the provided weights
  • Setting invalid weights may result in overweight blocks which are not secure (See Polkadot paper section 6.5.5)

Sources:

Note

It's better to set a weight to represent the worst-case scenario (i.e. weights should be greater than the average execution weight)

@PopcornPaws
Copy link
Contributor

Nice summary, thanks!

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

Successfully merging a pull request may close this issue.

3 participants