Skip to content

Commit 9691055

Browse files
aramikmdo-not-replywilwade
authored
Stateful storage pov optimization (#1757)
# Goal The goal of this PR is to evaluate and minimize PoV consumption by `stateful-storage` pallet. Closes #1782 # Discussion - refactored benchmarks to calculate the max of time and PoV - decreased `additional-trie-layers` number - decreased `MaxItemizedPageSizeBytes ` from 64KiB to around 10KiB (will allow around 292 of 32 bytes itemized public keys) # Improvements - by applying mentioned changes the PoV for `apply_item_actions` got reduced from **45KB** to **15KB** - by applying mentioned changes the PoV for `upsert` and `delete` pages got reduced from **12KB** to **6KB** # Future improvements - by using PoV clawback we can further reduce the PoV sizes. A [PR](paritytech/polkadot-sdk#1462) to track # Checklist - [x] Benchmarks added - [x] Weights updated --------- Co-authored-by: Frequency CI [bot] <do-not-reply@users.noreply.github.com> Co-authored-by: Wil Wade <wil.wade@unfinished.com>
1 parent 36c4e4b commit 9691055

27 files changed

+1084
-919
lines changed

pallets/capacity/src/weights.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//! Autogenerated weights for pallet_capacity
1919
//!
2020
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21-
//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
21+
//! DATE: 2023-11-14, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! WORST CASE MAP SIZE: `1000000`
23-
//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
23+
//! HOSTNAME: `benchmark-runner-44wtw-sz2gt`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
2424
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024
2525
2626
// Executed Command:
@@ -33,7 +33,7 @@
3333
// --chain=frequency-bench
3434
// --heap-pages=4096
3535
// --wasm-execution=compiled
36-
// --additional-trie-layers=20
36+
// --additional-trie-layers=5
3737
// --steps=20
3838
// --repeat=10
3939
// --output=./scripts/../pallets/capacity/src/weights.rs
@@ -74,9 +74,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
7474
fn stake() -> Weight {
7575
// Proof Size summary in bytes:
7676
// Measured: `223`
77-
// Estimated: `13674`
78-
// Minimum execution time: 43_127_000 picoseconds.
79-
Weight::from_parts(44_191_000, 13674)
77+
// Estimated: `6249`
78+
// Minimum execution time: 43_154_000 picoseconds.
79+
Weight::from_parts(44_525_000, 6249)
8080
.saturating_add(T::DbWeight::get().reads(6_u64))
8181
.saturating_add(T::DbWeight::get().writes(4_u64))
8282
}
@@ -89,9 +89,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
8989
fn withdraw_unstaked() -> Weight {
9090
// Proof Size summary in bytes:
9191
// Measured: `339`
92-
// Estimated: `13674`
93-
// Minimum execution time: 33_146_000 picoseconds.
94-
Weight::from_parts(34_058_000, 13674)
92+
// Estimated: `6249`
93+
// Minimum execution time: 33_031_000 picoseconds.
94+
Weight::from_parts(34_284_000, 6249)
9595
.saturating_add(T::DbWeight::get().reads(3_u64))
9696
.saturating_add(T::DbWeight::get().writes(2_u64))
9797
}
@@ -102,9 +102,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
102102
fn on_initialize() -> Weight {
103103
// Proof Size summary in bytes:
104104
// Measured: `0`
105-
// Estimated: `10399`
106-
// Minimum execution time: 4_040_000 picoseconds.
107-
Weight::from_parts(4_215_000, 10399)
105+
// Estimated: `2974`
106+
// Minimum execution time: 3_876_000 picoseconds.
107+
Weight::from_parts(4_036_000, 2974)
108108
.saturating_add(T::DbWeight::get().reads(2_u64))
109109
.saturating_add(T::DbWeight::get().writes(1_u64))
110110
}
@@ -121,9 +121,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
121121
fn unstake() -> Weight {
122122
// Proof Size summary in bytes:
123123
// Measured: `433`
124-
// Estimated: `13674`
125-
// Minimum execution time: 38_156_000 picoseconds.
126-
Weight::from_parts(39_905_000, 13674)
124+
// Estimated: `6249`
125+
// Minimum execution time: 38_465_000 picoseconds.
126+
Weight::from_parts(39_656_000, 6249)
127127
.saturating_add(T::DbWeight::get().reads(5_u64))
128128
.saturating_add(T::DbWeight::get().writes(4_u64))
129129
}
@@ -133,8 +133,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
133133
// Proof Size summary in bytes:
134134
// Measured: `0`
135135
// Estimated: `0`
136-
// Minimum execution time: 6_429_000 picoseconds.
137-
Weight::from_parts(6_896_000, 0)
136+
// Minimum execution time: 6_805_000 picoseconds.
137+
Weight::from_parts(7_569_000, 0)
138138
.saturating_add(T::DbWeight::get().writes(1_u64))
139139
}
140140
}
@@ -156,9 +156,9 @@ impl WeightInfo for () {
156156
fn stake() -> Weight {
157157
// Proof Size summary in bytes:
158158
// Measured: `223`
159-
// Estimated: `13674`
160-
// Minimum execution time: 43_127_000 picoseconds.
161-
Weight::from_parts(44_191_000, 13674)
159+
// Estimated: `6249`
160+
// Minimum execution time: 43_154_000 picoseconds.
161+
Weight::from_parts(44_525_000, 6249)
162162
.saturating_add(RocksDbWeight::get().reads(6_u64))
163163
.saturating_add(RocksDbWeight::get().writes(4_u64))
164164
}
@@ -171,9 +171,9 @@ impl WeightInfo for () {
171171
fn withdraw_unstaked() -> Weight {
172172
// Proof Size summary in bytes:
173173
// Measured: `339`
174-
// Estimated: `13674`
175-
// Minimum execution time: 33_146_000 picoseconds.
176-
Weight::from_parts(34_058_000, 13674)
174+
// Estimated: `6249`
175+
// Minimum execution time: 33_031_000 picoseconds.
176+
Weight::from_parts(34_284_000, 6249)
177177
.saturating_add(RocksDbWeight::get().reads(3_u64))
178178
.saturating_add(RocksDbWeight::get().writes(2_u64))
179179
}
@@ -184,9 +184,9 @@ impl WeightInfo for () {
184184
fn on_initialize() -> Weight {
185185
// Proof Size summary in bytes:
186186
// Measured: `0`
187-
// Estimated: `10399`
188-
// Minimum execution time: 4_040_000 picoseconds.
189-
Weight::from_parts(4_215_000, 10399)
187+
// Estimated: `2974`
188+
// Minimum execution time: 3_876_000 picoseconds.
189+
Weight::from_parts(4_036_000, 2974)
190190
.saturating_add(RocksDbWeight::get().reads(2_u64))
191191
.saturating_add(RocksDbWeight::get().writes(1_u64))
192192
}
@@ -203,9 +203,9 @@ impl WeightInfo for () {
203203
fn unstake() -> Weight {
204204
// Proof Size summary in bytes:
205205
// Measured: `433`
206-
// Estimated: `13674`
207-
// Minimum execution time: 38_156_000 picoseconds.
208-
Weight::from_parts(39_905_000, 13674)
206+
// Estimated: `6249`
207+
// Minimum execution time: 38_465_000 picoseconds.
208+
Weight::from_parts(39_656_000, 6249)
209209
.saturating_add(RocksDbWeight::get().reads(5_u64))
210210
.saturating_add(RocksDbWeight::get().writes(4_u64))
211211
}
@@ -215,8 +215,8 @@ impl WeightInfo for () {
215215
// Proof Size summary in bytes:
216216
// Measured: `0`
217217
// Estimated: `0`
218-
// Minimum execution time: 6_429_000 picoseconds.
219-
Weight::from_parts(6_896_000, 0)
218+
// Minimum execution time: 6_805_000 picoseconds.
219+
Weight::from_parts(7_569_000, 0)
220220
.saturating_add(RocksDbWeight::get().writes(1_u64))
221221
}
222222
}

pallets/frequency-tx-payment/src/weights.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//! Autogenerated weights for pallet_frequency_tx_payment
1919
//!
2020
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21-
//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
21+
//! DATE: 2023-11-14, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! WORST CASE MAP SIZE: `1000000`
23-
//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
23+
//! HOSTNAME: `benchmark-runner-44wtw-sz2gt`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
2424
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024
2525
2626
// Executed Command:
@@ -33,7 +33,7 @@
3333
// --chain=frequency-bench
3434
// --heap-pages=4096
3535
// --wasm-execution=compiled
36-
// --additional-trie-layers=20
36+
// --additional-trie-layers=5
3737
// --steps=20
3838
// --repeat=10
3939
// --output=./scripts/../pallets/frequency-tx-payment/src/weights.rs
@@ -60,18 +60,18 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6060
// Proof Size summary in bytes:
6161
// Measured: `0`
6262
// Estimated: `0`
63-
// Minimum execution time: 3_362_000 picoseconds.
64-
Weight::from_parts(3_551_000, 0)
63+
// Minimum execution time: 3_294_000 picoseconds.
64+
Weight::from_parts(3_499_000, 0)
6565
}
6666
/// The range of component `n` is `[0, 10]`.
6767
fn pay_with_capacity_batch_all(n: u32, ) -> Weight {
6868
// Proof Size summary in bytes:
6969
// Measured: `0`
7070
// Estimated: `0`
71-
// Minimum execution time: 7_061_000 picoseconds.
72-
Weight::from_parts(8_127_386, 0)
73-
// Standard Error: 16_699
74-
.saturating_add(Weight::from_parts(4_653_714, 0).saturating_mul(n.into()))
71+
// Minimum execution time: 7_318_000 picoseconds.
72+
Weight::from_parts(8_276_383, 0)
73+
// Standard Error: 12_166
74+
.saturating_add(Weight::from_parts(4_732_333, 0).saturating_mul(n.into()))
7575
}
7676
}
7777

@@ -81,17 +81,17 @@ impl WeightInfo for () {
8181
// Proof Size summary in bytes:
8282
// Measured: `0`
8383
// Estimated: `0`
84-
// Minimum execution time: 3_362_000 picoseconds.
85-
Weight::from_parts(3_551_000, 0)
84+
// Minimum execution time: 3_294_000 picoseconds.
85+
Weight::from_parts(3_499_000, 0)
8686
}
8787
/// The range of component `n` is `[0, 10]`.
8888
fn pay_with_capacity_batch_all(n: u32, ) -> Weight {
8989
// Proof Size summary in bytes:
9090
// Measured: `0`
9191
// Estimated: `0`
92-
// Minimum execution time: 7_061_000 picoseconds.
93-
Weight::from_parts(8_127_386, 0)
94-
// Standard Error: 16_699
95-
.saturating_add(Weight::from_parts(4_653_714, 0).saturating_mul(n.into()))
92+
// Minimum execution time: 7_318_000 picoseconds.
93+
Weight::from_parts(8_276_383, 0)
94+
// Standard Error: 12_166
95+
.saturating_add(Weight::from_parts(4_732_333, 0).saturating_mul(n.into()))
9696
}
9797
}

pallets/handles/src/weights.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//! Autogenerated weights for pallet_handles
1919
//!
2020
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21-
//! DATE: 2023-10-30, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
21+
//! DATE: 2023-11-14, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
2222
//! WORST CASE MAP SIZE: `1000000`
23-
//! HOSTNAME: `benchmark-runner-44wtw-bw25f`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
23+
//! HOSTNAME: `benchmark-runner-44wtw-sz2gt`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz`
2424
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("frequency-bench"), DB CACHE: 1024
2525
2626
// Executed Command:
@@ -33,7 +33,7 @@
3333
// --chain=frequency-bench
3434
// --heap-pages=4096
3535
// --wasm-execution=compiled
36-
// --additional-trie-layers=20
36+
// --additional-trie-layers=5
3737
// --steps=20
3838
// --repeat=10
3939
// --output=./scripts/../pallets/handles/src/weights.rs
@@ -69,11 +69,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6969
fn claim_handle(b: u32, ) -> Weight {
7070
// Proof Size summary in bytes:
7171
// Measured: `191`
72-
// Estimated: `12434`
73-
// Minimum execution time: 81_465_000 picoseconds.
74-
Weight::from_parts(83_332_398, 12434)
75-
// Standard Error: 9_174
76-
.saturating_add(Weight::from_parts(77_143, 0).saturating_mul(b.into()))
72+
// Estimated: `5009`
73+
// Minimum execution time: 82_418_000 picoseconds.
74+
Weight::from_parts(84_250_657, 5009)
75+
// Standard Error: 18_982
76+
.saturating_add(Weight::from_parts(75_863, 0).saturating_mul(b.into()))
7777
.saturating_add(T::DbWeight::get().reads(3_u64))
7878
.saturating_add(T::DbWeight::get().writes(3_u64))
7979
}
@@ -89,11 +89,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
8989
fn change_handle(b: u32, ) -> Weight {
9090
// Proof Size summary in bytes:
9191
// Measured: `297 + b * (1 ±0)`
92-
// Estimated: `12434`
93-
// Minimum execution time: 91_552_000 picoseconds.
94-
Weight::from_parts(93_641_136, 12434)
95-
// Standard Error: 10_045
96-
.saturating_add(Weight::from_parts(152_851, 0).saturating_mul(b.into()))
92+
// Estimated: `5009`
93+
// Minimum execution time: 93_554_000 picoseconds.
94+
Weight::from_parts(94_507_705, 5009)
95+
// Standard Error: 8_136
96+
.saturating_add(Weight::from_parts(165_626, 0).saturating_mul(b.into()))
9797
.saturating_add(T::DbWeight::get().reads(3_u64))
9898
.saturating_add(T::DbWeight::get().writes(4_u64))
9999
}
@@ -106,9 +106,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
106106
fn retire_handle() -> Weight {
107107
// Proof Size summary in bytes:
108108
// Measured: `306`
109-
// Estimated: `12434`
110-
// Minimum execution time: 22_019_000 picoseconds.
111-
Weight::from_parts(22_866_000, 12434)
109+
// Estimated: `5009`
110+
// Minimum execution time: 22_739_000 picoseconds.
111+
Weight::from_parts(23_360_000, 5009)
112112
.saturating_add(T::DbWeight::get().reads(2_u64))
113113
.saturating_add(T::DbWeight::get().writes(2_u64))
114114
}
@@ -128,11 +128,11 @@ impl WeightInfo for () {
128128
fn claim_handle(b: u32, ) -> Weight {
129129
// Proof Size summary in bytes:
130130
// Measured: `191`
131-
// Estimated: `12434`
132-
// Minimum execution time: 81_465_000 picoseconds.
133-
Weight::from_parts(83_332_398, 12434)
134-
// Standard Error: 9_174
135-
.saturating_add(Weight::from_parts(77_143, 0).saturating_mul(b.into()))
131+
// Estimated: `5009`
132+
// Minimum execution time: 82_418_000 picoseconds.
133+
Weight::from_parts(84_250_657, 5009)
134+
// Standard Error: 18_982
135+
.saturating_add(Weight::from_parts(75_863, 0).saturating_mul(b.into()))
136136
.saturating_add(RocksDbWeight::get().reads(3_u64))
137137
.saturating_add(RocksDbWeight::get().writes(3_u64))
138138
}
@@ -148,11 +148,11 @@ impl WeightInfo for () {
148148
fn change_handle(b: u32, ) -> Weight {
149149
// Proof Size summary in bytes:
150150
// Measured: `297 + b * (1 ±0)`
151-
// Estimated: `12434`
152-
// Minimum execution time: 91_552_000 picoseconds.
153-
Weight::from_parts(93_641_136, 12434)
154-
// Standard Error: 10_045
155-
.saturating_add(Weight::from_parts(152_851, 0).saturating_mul(b.into()))
151+
// Estimated: `5009`
152+
// Minimum execution time: 93_554_000 picoseconds.
153+
Weight::from_parts(94_507_705, 5009)
154+
// Standard Error: 8_136
155+
.saturating_add(Weight::from_parts(165_626, 0).saturating_mul(b.into()))
156156
.saturating_add(RocksDbWeight::get().reads(3_u64))
157157
.saturating_add(RocksDbWeight::get().writes(4_u64))
158158
}
@@ -165,9 +165,9 @@ impl WeightInfo for () {
165165
fn retire_handle() -> Weight {
166166
// Proof Size summary in bytes:
167167
// Measured: `306`
168-
// Estimated: `12434`
169-
// Minimum execution time: 22_019_000 picoseconds.
170-
Weight::from_parts(22_866_000, 12434)
168+
// Estimated: `5009`
169+
// Minimum execution time: 22_739_000 picoseconds.
170+
Weight::from_parts(23_360_000, 5009)
171171
.saturating_add(RocksDbWeight::get().reads(2_u64))
172172
.saturating_add(RocksDbWeight::get().writes(2_u64))
173173
}

0 commit comments

Comments
 (0)