diff --git a/substrate/bin/node/bench/Cargo.toml b/substrate/bin/node/bench/Cargo.toml index d8f23f21049a09983bb5ddef861df635d265ef43..e57383975562fa5f05001a8c72076fd1fdada67c 100644 --- a/substrate/bin/node/bench/Cargo.toml +++ b/substrate/bin/node/bench/Cargo.toml @@ -15,7 +15,7 @@ node-testing = { version = "2.0.0-dev", path = "../testing" } sc-cli = { version = "0.8.0-dev", path = "../../../client/cli" } sc-client-api = { version = "2.0.0-dev", path = "../../../client/api/" } sp-runtime = { version = "2.0.0-dev", path = "../../../primitives/runtime" } -sp-state-machine = { version = "0.8.0-alpha.5", path = "../../../primitives/state-machine" } +sp-state-machine = { version = "0.8.0-dev", path = "../../../primitives/state-machine" } serde = "1.0.101" serde_json = "1.0.41" structopt = "0.3" diff --git a/substrate/bin/node/bench/src/core.rs b/substrate/bin/node/bench/src/core.rs index 9105fcbd0170f47962cd26bb3e1e479274ee7f3e..7a345f7a5bd99cccb37ff745bceb2fb252e25add 100644 --- a/substrate/bin/node/bench/src/core.rs +++ b/substrate/bin/node/bench/src/core.rs @@ -58,7 +58,7 @@ pub struct BenchmarkOutput { average: u64, } -struct NsFormatter(u64); +pub struct NsFormatter(pub u64); impl fmt::Display for NsFormatter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/substrate/bin/node/bench/src/import.rs b/substrate/bin/node/bench/src/import.rs index 2dea292ab0088cafd488e9c613c1bc003be9a54c..a6e4eb2514e890b6133400c37d2db67cef06ccd7 100644 --- a/substrate/bin/node/bench/src/import.rs +++ b/substrate/bin/node/bench/src/import.rs @@ -37,8 +37,17 @@ use sp_runtime::generic::BlockId; use crate::core::{self, Path, Mode}; -#[derive(Clone, Copy, Debug)] -pub enum SizeType { Small, Medium, Large } +#[derive(Clone, Copy, Debug, derive_more::Display)] +pub enum SizeType { + #[display(fmt = "small")] + Small, + #[display(fmt = "medium")] + Medium, + #[display(fmt = "large")] + Large, + #[display(fmt = "full")] + Full, +} impl SizeType { fn transactions(&self) -> usize { @@ -46,6 +55,7 @@ impl SizeType { SizeType::Small => 10, SizeType::Medium => 100, SizeType::Large => 500, + SizeType::Full => 4000, } } } @@ -77,18 +87,17 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription { KeyTypes::Ed25519 => path.push("ed25519"), } - match self.size { - SizeType::Small => path.push("small"), - SizeType::Medium => path.push("medium"), - SizeType::Large => path.push("large"), - } + path.push(&format!("{}", self.size)); path } fn setup(self: Box<Self>) -> Box<dyn core::Benchmark> { let profile = self.profile; - let mut bench_db = BenchDb::with_key_types(self.size.transactions(), self.key_types); + let mut bench_db = BenchDb::with_key_types( + 50_000, + self.key_types + ); let block = bench_db.generate_block(BlockType::RandomTransfers(self.size.transactions())); Box::new(ImportBenchmark { database: bench_db, @@ -99,8 +108,14 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription { fn name(&self) -> Cow<'static, str> { match self.profile { - Profile::Wasm => "Import benchmark (random transfers, wasm)".into(), - Profile::Native => "Import benchmark (random transfers, native)".into(), + Profile::Wasm => format!( + "Import benchmark (random transfers, wasm, {} block)", + self.size, + ).into(), + Profile::Native => format!( + "Import benchmark (random transfers, native, {} block)", + self.size, + ).into(), } } } @@ -113,12 +128,16 @@ impl core::Benchmark for ImportBenchmark { .expect("Failed to get runtime version") .spec_version; + if mode == Mode::Profile { + std::thread::park_timeout(std::time::Duration::from_secs(3)); + } + let start = std::time::Instant::now(); context.import_block(self.block.clone()); let elapsed = start.elapsed(); if mode == Mode::Profile { - std::thread::park_timeout(std::time::Duration::from_secs(2)); + std::thread::park_timeout(std::time::Duration::from_secs(1)); } log::info!( diff --git a/substrate/bin/node/bench/src/main.rs b/substrate/bin/node/bench/src/main.rs index c821746b33ad7c9f5a1069b7aaa95a45e094c321..48f1213d621c351da44a882a126ab891d1162c05 100644 --- a/substrate/bin/node/bench/src/main.rs +++ b/substrate/bin/node/bench/src/main.rs @@ -76,6 +76,16 @@ fn main() { key_types: KeyTypes::Ed25519, size: SizeType::Medium, }, + ImportBenchmarkDescription { + profile: Profile::Wasm, + key_types: KeyTypes::Sr25519, + size: SizeType::Full, + }, + ImportBenchmarkDescription { + profile: Profile::Native, + key_types: KeyTypes::Sr25519, + size: SizeType::Full, + }, size in [SizeType::Small, SizeType::Large] => ImportBenchmarkDescription { profile: Profile::Native, diff --git a/substrate/primitives/io/src/batch_verifier.rs b/substrate/primitives/io/src/batch_verifier.rs index a23b8fcbc2d5a3a4e1c48f78512cc825ef5c1828..82ce0b04ef0bc6eb22b5bb3cd80caf6d807ffd5b 100644 --- a/substrate/primitives/io/src/batch_verifier.rs +++ b/substrate/primitives/io/src/batch_verifier.rs @@ -117,6 +117,7 @@ impl BatchVerifier { use std::sync::{Mutex, Condvar}; let pending = std::mem::replace(&mut self.pending_tasks, vec![]); + let started = std::time::Instant::now(); log::trace!( target: "runtime", @@ -158,6 +159,12 @@ impl BatchVerifier { let _ = cond_var.wait(mtx).expect("Waiting can only fail when the mutex waited on is poisoned; qed"); } + log::trace!( + target: "runtime", + "Finalization of batch verification took {} ms", + started.elapsed().as_millis(), + ); + !self.invalid.swap(false, AtomicOrdering::Relaxed) } }