Factor DB weights out into their own files (#10908)

* Factor DB weights out into their own files

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Review fixes

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix CI

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Weights in own mod

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-02-23 20:58:53 +01:00
committed by GitHub
parent 26ec5d71c8
commit 9552835ccd
3 changed files with 135 additions and 13 deletions
+9 -13
View File
@@ -127,6 +127,9 @@
//! - Ubuntu 19.10 (GNU/Linux 5.3.0-18-generic x86_64)
//! - rustc 1.42.0 (b8cedc004 2020-03-09)
mod paritydb_weights;
mod rocksdb_weights;
use crate::dispatch::{DispatchError, DispatchErrorWithPostInfo, DispatchResultWithPostInfo};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
@@ -152,7 +155,7 @@ pub type Weight = u64;
/// These constants are specific to FRAME, and the current implementation of its various components.
/// For example: FRAME System, FRAME Executive, our FRAME support libraries, etc...
pub mod constants {
use super::{RuntimeDbWeight, Weight};
use super::Weight;
use crate::parameter_types;
pub const WEIGHT_PER_SECOND: Weight = 1_000_000_000_000;
@@ -165,19 +168,12 @@ pub mod constants {
pub const BlockExecutionWeight: Weight = 5 * WEIGHT_PER_MILLIS;
/// Executing 10,000 System remarks (no-op) txs takes ~1.26 seconds -> ~125 µs per tx
pub const ExtrinsicBaseWeight: Weight = 125 * WEIGHT_PER_MICROS;
/// By default, Substrate uses RocksDB, so this will be the weight used throughout
/// the runtime.
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 25 * WEIGHT_PER_MICROS, // ~25 µs @ 200,000 items
write: 100 * WEIGHT_PER_MICROS, // ~100 µs @ 200,000 items
};
/// ParityDB can be enabled with a feature flag, but is still experimental. These weights
/// are available for brave runtime engineers who may want to try this out as default.
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 8 * WEIGHT_PER_MICROS, // ~8 µs @ 200,000 items
write: 50 * WEIGHT_PER_MICROS, // ~50 µs @ 200,000 items
};
}
// Expose the DB weights.
pub use super::{
paritydb_weights::constants::ParityDbWeight, rocksdb_weights::constants::RocksDbWeight,
};
}
/// Means of weighing some particular kind of data (`T`).