Make election benchmarks more *memory-aware* (#9286)

* Make benchmarks a bit better with mem

* Make election benchmarks more *memory-aware*

* Fix a few errors

* 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

* Manually fix the weights

* Update lock file

* remove dupe

* Fix tests

* cargo update pwasm

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Kian Paimani
2021-07-09 21:55:31 +02:00
committed by GitHub
parent 9fc86cb55f
commit 3850a43323
11 changed files with 356 additions and 148 deletions
@@ -22,15 +22,15 @@ use frame_support::traits::StorageInfo;
use sc_cli::{SharedParams, CliConfiguration, ExecutionStrategy, Result};
use sc_client_db::BenchmarkingState;
use sc_executor::NativeExecutor;
use sp_state_machine::StateMachine;
use sp_externalities::Extensions;
use sc_service::{Configuration, NativeExecutionDispatch};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use sp_core::offchain::{OffchainWorkerExt, testing::TestOffchainExt};
use sp_keystore::{
SyncCryptoStorePtr, KeystoreExt,
testing::KeyStore,
use sp_core::offchain::{
testing::{TestOffchainExt, TestTransactionPoolExt},
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
};
use sp_externalities::Extensions;
use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use sp_state_machine::StateMachine;
use std::{fmt::Debug, sync::Arc};
impl BenchmarkCmd {
@@ -73,7 +73,10 @@ impl BenchmarkCmd {
let mut extensions = Extensions::default();
extensions.register(KeystoreExt(Arc::new(KeyStore::new()) as SyncCryptoStorePtr));
let (offchain, _) = TestOffchainExt::new();
extensions.register(OffchainWorkerExt::new(offchain));
let (pool, _) = TestTransactionPoolExt::new();
extensions.register(OffchainWorkerExt::new(offchain.clone()));
extensions.register(OffchainDbExt::new(offchain));
extensions.register(TransactionPoolExt::new(pool));
let result = StateMachine::<_, _, NumberFor<BB>, _>::new(
&state,
@@ -85,7 +85,8 @@ pub struct BenchmarkCmd {
#[structopt(long)]
pub output_analysis: Option<String>,
/// Set the heap pages while running benchmarks.
/// Set the heap pages while running benchmarks. If not set, the default value from the client
/// is used.
#[structopt(long)]
pub heap_pages: Option<u64>,
@@ -93,7 +94,8 @@ pub struct BenchmarkCmd {
#[structopt(long)]
pub no_verify: bool,
/// Display and run extra benchmarks that would otherwise not be needed for weight construction.
/// Display and run extra benchmarks that would otherwise not be needed for weight
/// construction.
#[structopt(long)]
pub extra: bool,
@@ -120,7 +122,7 @@ pub struct BenchmarkCmd {
value_name = "METHOD",
possible_values = &WasmExecutionMethod::variants(),
case_insensitive = true,
default_value = "Interpreted"
default_value = "compiled"
)]
pub wasm_method: WasmExecutionMethod,