You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
benchmark: storage: Make read/write benchmarks more accurate (#7867)
There are a few problems with these read/write benchmarks which makes
them produce misleading results, especially when we enable the
trie-cache.
The problems are:
- Both benchmarks run without PoV recorder enabled, that is not accurate
for parachains because without the PoV recorder, you can directly access
the key from the value cache, while with the PoV recorder you still need
to do the walk through which uses the Node cache, e.g:
https://github.com/paritytech/trie/blob/master/trie-db/src/lookup.rs#L446.
To fix this I added I parameter enable-pov-recorder which is meant to be
used when generating the weights for parachains.
- Every write measures both the time to update the key and to compute
the storage root and commit all the changes, which is not accurate
because the storage root is computed only once at the end of the block.
For this I added a new argument --batch-size, which is used to determine
how many keys to update and performs the storage root computation only
once, it then calculate the per key write cost as `durations /
batch-size`.
- For reads when you run with the PoV recorder, there is also a benefit
from running with the same recorder rather than creating a different
recorder every read, so we again use the `batch-size` for than to obtain
the amortised cost of a read.
- bench warmup seemed to not warmup child keys even when
`include-child-trees`, so I fixed that as well
## Results on reference hardware, asset-hub-westend state
| Setup | Batch size| Amortized cost of a key write(**ns**) | Amortized
cost of a key read(**ns**)|
|--------|--------|--------|--------|
|Without TrieCache, Without PoV Recorder|1|88_521|46_981|
|Without TrieCache, With PoV Recorder|1|95_161|48_711|
|With TrieCache, Without PoV Recorder|1|66_008|528|
|With TrieCache, With PoV Recorder|1|73_145|12_142|
|Without TrieCache, Without PoV Recorder|1000|52_646|72_434|
|Without TrieCache, With PoV Recorder|1000|54_896|50_267|
|With TrieCache, Without PoV Recorder|1000|30_585|497|
|With TrieCache, With PoV Recorder|1000|33_765|6_928|
|Without TrieCache, Without PoV Recorder|10_000|48_945|52_730|
|Without TrieCache, With PoV Recorder|10_000|50_285|49_860|
|With TrieCache, Without PoV Recorder|10_000|25_903|484|
|With TrieCache, With PoV Recorder|10_000|28_417|7_153|
|Without TrieCache, Without PoV Recorder|100_000|31_359|45_839|
|Without TrieCache, With PoV Recorder|100_000|32_932|48_393|
|With TrieCache, Without PoV Recorder|100_000|20_255|493|
|*With TrieCache, With PoV Recorder*, to be used|100_000|21_998|6_908|
## Results on reference hardware asset-hub-polkadot state
| Setup | Batch size| Amortized cost of a key write(**ns**) | Amortized
cost of a key read(**ns**)|
|--------|--------|--------|--------|
|Without TrieCache, Without PoV Recorder|1|102_239|56_209|
|Without TrieCache, With PoV Recorder|1|106_659|54_256|
|With TrieCache, Without PoV Recorder|1|85_419|608|
|With TrieCache, With PoV Recorder|1|95_221|13_567|
|Without TrieCache, Without PoV Recorder|1000|61_574|53_767|
|Without TrieCache, With PoV Recorder|1000|64_770|66_162|
|With TrieCache, Without PoV Recorder|1000|35_879|597|
|With TrieCache, With PoV Recorder|1000|39_464|8_482|
|Without TrieCache, Without PoV Recorder|10_000|62_465|58_236|
|Without TrieCache, With PoV Recorder|10_000|65_082|95_118|
|With TrieCache, Without PoV Recorder|10_000|32_259|601|
|With TrieCache, With PoV Recorder|10_000|34_620|8_810|
|Without TrieCache, Without PoV Recorder|100_000|43_794|69_157|
|Without TrieCache, With PoV Recorder|100_000|45_060|66_343|
|With TrieCache, Without PoV Recorder|100_000|25_327|596|
|*With TrieCache, With PoV Recorder*, to be used|100_000|27_622|8_598|
## Results on my local machine with westend-assethub state.
| Setup | Batch size| Amortized cost of a key write(**ns**) | Amortized
cost of a key read(**ns**)|
|--------|--------|--------|--------|
|Without TrieCache, Without PoV Recorder|1| 55_443|27_510|
|Without TrieCache, With PoV Recorder|1|143_189|105_103|
|With TrieCache, Without PoV Recorder|1|37_519|370|
|With TrieCache, With PoV Recorder|1|42_569|7_309|
|Without TrieCache, Without PoV Recorder|1000| 29_364|25_150|
|Without TrieCache, With PoV Recorder|1000|33_221|107_349|
|With TrieCache, Without PoV Recorder|1000|18_355|370|
|With TrieCache, With PoV Recorder|1000|19_883|4_063|
|Without TrieCache, Without PoV Recorder|10_000| 28_336|27_765|
|Without TrieCache, With PoV Recorder|10_000|29_673|62_392|
|With TrieCache, Without PoV Recorder|10_000|15_102|370|
|With TrieCache, With PoV Recorder|10_000|16_461|4_124|
|Without TrieCache, Without PoV Recorder|100_000| 18_935|27_151|
|Without TrieCache, With PoV Recorder|100_000|19_681|48_393|
|With TrieCache, Without PoV Recorder|100_000|12_569|362|
|*With TrieCache, With PoV Recorder*, to be used|100_000|13_469|3_895|
Fixes: #7535
## Todo:
- [x] Run this benchmarks on reference hardware on configuration variant
closest to the production environment.
---------
Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
0 commit comments