Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d998b12
Base features and traits.
kianenigma Jan 15, 2021
5aea9cc
pallet and unsigned phase
kianenigma Jan 15, 2021
632e107
Undo bad formattings.
kianenigma Jan 15, 2021
c52e65d
Master.into()
kianenigma Jan 18, 2021
b4fc5e1
some formatting cleanup.
kianenigma Jan 18, 2021
cc26881
Small self-cleanup.
kianenigma Jan 18, 2021
67a9fae
Master.into()
kianenigma Jan 27, 2021
75eca3f
Make it all build
kianenigma Jan 27, 2021
8daec3a
self-review
kianenigma Jan 27, 2021
49613ed
Some doc tests.
kianenigma Jan 27, 2021
35f1faf
Some changes from other PR
kianenigma Jan 27, 2021
e01cacc
Fix session test
kianenigma Jan 27, 2021
6278150
Merge branch 'master' into kiz-election-provider-2-two-phase-unsigned
shawntabrizi Feb 4, 2021
4c516cb
Update Cargo.lock
shawntabrizi Feb 4, 2021
8c8d1e6
Update frame/election-provider-multi-phase/src/lib.rs
kianenigma Feb 11, 2021
4b58c91
Some review comments
kianenigma Feb 11, 2021
f4029aa
Merge branch 'kiz-election-provider-2-two-phase-unsigned' of github.c…
kianenigma Feb 11, 2021
f16ac88
Master.into()
kianenigma Feb 11, 2021
528917e
Rename + make encode/decode
kianenigma Feb 12, 2021
1a5794a
Do an assert as well, just in case.
kianenigma Feb 12, 2021
01e63ed
Fix build
kianenigma Feb 12, 2021
4ccecdf
Update frame/election-provider-multi-phase/src/unsigned.rs
kianenigma Feb 12, 2021
83a789e
Las comment
kianenigma Feb 12, 2021
adb3618
Merge branch 'kiz-election-provider-2-two-phase-unsigned' of github.c…
kianenigma Feb 12, 2021
7c71df0
fix staking fuzzer.
kianenigma Feb 12, 2021
12b1640
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Feb 12, 2021
6397d4a
Add one last layer of feasibility check as well.
kianenigma Feb 12, 2021
80d3c31
Merge branch 'kiz-election-provider-2-two-phase-unsigned' of github.c…
kianenigma Feb 12, 2021
7d6f6ad
Last fixes to benchmarks
kianenigma Feb 12, 2021
2e28437
Some more docs.
kianenigma Feb 12, 2021
5fda744
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Feb 12, 2021
1ce6c8e
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Feb 12, 2021
f63c5b8
Some nits
kianenigma Feb 12, 2021
8029c01
Merge branch 'kiz-election-provider-2-two-phase-unsigned' of github.c…
kianenigma Feb 12, 2021
70f4191
Merge remote-tracking branch 'origin/master' into kiz-election-provid…
Feb 13, 2021
701e4a2
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Feb 13, 2021
ea531e1
Fix doc
kianenigma Feb 17, 2021
c2a3286
Upstream.into()
kianenigma Feb 17, 2021
16fe4f7
Master.into()
kianenigma Feb 17, 2021
2c6ac80
Mkae ci green
kianenigma Feb 17, 2021
0bcc776
Merge branch 'master' of github.com:paritytech/substrate into kiz-ele…
kianenigma Feb 18, 2021
9328b71
Master.into()
kianenigma Feb 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
…/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_election_provider_multi_phase --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/election-provider-multi-phase/src/weights.rs --template=./.maintain/frame-weight-template.hbs
  • Loading branch information
Parity Benchmarking Bot committed Feb 12, 2021
commit 5fda74464bfc34d9914626043b32dc832d203d16
68 changes: 34 additions & 34 deletions frame/election-provider-multi-phase/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,95 +56,95 @@ pub trait WeightInfo {
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn on_initialize_nothing() -> Weight {
(23_272_000 as Weight)
(23_608_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI most of these reads are in the predict_next_election from staking's side... This is one of the aspects of this PR that I am still not super happy with and gladly accept calls to rethink it: how we predict when next election happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we do this every block, maybe we can do it better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but also, at some point, if they are read everyblock, we can consider them always in cache no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are read only by me afaik, so sadly I think they are not cached in any way.

Noting that we don't have any cache that caches stuff from this block to the next one right? it is only intra-block caching.

Copy link
Contributor

@gui1117 gui1117 Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, but there can be a cache inter block, for reads, in client/db/src/storage_cache.rs maybe @cheme knows about it.

Copy link
Contributor

@cheme cheme Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, 'client/db/src/storage_cache.rs' is caching between consecutive blocks, got reset if there is a reorg though, and it's lru with client specific size so can't really make expectation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember thinking on how to avoid redundant calculation between blocks, and thought of something like: calculated_cached_value(cache_key, source: [storage_keys | storage_prefix], fn calculate(source)-> result) -> result that would either:

  • take a cached result from a previous block if no source value did change and a cache is implemented (this requires to invalidate cache on any key access from state-machine (with a radix trie filter for instance))
  • calculate the result from the function 'calculate', then return it and cache it (if such cache is implemented).
    But this would require new host function to access cache and invalidate on source storage access.

But tbh it is not very easy to implement and is only useful for costly computation.
But in case of costly computation we can also simply write the result in state and have the invalidate logic coded in the runtime. It is possibly less efficient but since it will behave the same between client, calculated weight can benefit from it.

}
fn on_initialize_open_signed() -> Weight {
(78_018_000 as Weight)
(80_022_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn on_initialize_open_unsigned_with_snapshot() -> Weight {
(76_963_000 as Weight)
(79_071_000 as Weight)
.saturating_add(T::DbWeight::get().reads(7 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn on_initialize_open_unsigned_without_snapshot() -> Weight {
(21_235_000 as Weight)
(21_407_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 22_000
.saturating_add((4_261_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 21_000
.saturating_add((4_113_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 73_000
.saturating_add((311_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 22_000
.saturating_add((13_490_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 110_000
.saturating_add((4_677_000 as Weight).saturating_mul(d as Weight))
.saturating_add((48_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 21_000
.saturating_add((13_747_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 109_000
.saturating_add((4_526_000 as Weight).saturating_mul(d as Weight))
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 12_000
.saturating_add((4_335_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 41_000
.saturating_add((564_000 as Weight).saturating_mul(t as Weight))
.saturating_add((4_190_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 40_000
.saturating_add((494_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 12_000
.saturating_add((10_563_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 62_000
.saturating_add((4_750_000 as Weight).saturating_mul(d as Weight))
.saturating_add((10_391_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 60_000
.saturating_add((4_573_000 as Weight).saturating_mul(d as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
}
}

// For backwards compatibility and tests
impl WeightInfo for () {
fn on_initialize_nothing() -> Weight {
(23_272_000 as Weight)
(23_608_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
}
fn on_initialize_open_signed() -> Weight {
(78_018_000 as Weight)
(80_022_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
fn on_initialize_open_unsigned_with_snapshot() -> Weight {
(76_963_000 as Weight)
(79_071_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
fn on_initialize_open_unsigned_without_snapshot() -> Weight {
(21_235_000 as Weight)
(21_407_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn submit_unsigned(v: u32, t: u32, a: u32, d: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 22_000
.saturating_add((4_261_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 21_000
.saturating_add((4_113_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 73_000
.saturating_add((311_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 22_000
.saturating_add((13_490_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 110_000
.saturating_add((4_677_000 as Weight).saturating_mul(d as Weight))
.saturating_add((48_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 21_000
.saturating_add((13_747_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 109_000
.saturating_add((4_526_000 as Weight).saturating_mul(d as Weight))
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
fn feasibility_check(v: u32, t: u32, a: u32, d: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 12_000
.saturating_add((4_335_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 41_000
.saturating_add((564_000 as Weight).saturating_mul(t as Weight))
.saturating_add((4_190_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 40_000
.saturating_add((494_000 as Weight).saturating_mul(t as Weight))
// Standard Error: 12_000
.saturating_add((10_563_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 62_000
.saturating_add((4_750_000 as Weight).saturating_mul(d as Weight))
.saturating_add((10_391_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 60_000
.saturating_add((4_573_000 as Weight).saturating_mul(d as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
}
}