fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
@@ -4,7 +4,7 @@ This crate contains commands to benchmark various aspects of Bizinikiwi and the
|
||||
The goal is to have a comprehensive suite of benchmarks that cover all aspects of Bizinikiwi and the hardware that its
|
||||
running on.
|
||||
There exist fundamentally two ways to use this crate. A node-integrated CLI version, and a freestanding CLI. If you are
|
||||
only interested in pallet benchmarking, then skip ahead to the [Freestanding CLI](#freestanding-cli).
|
||||
only interested in pezpallet benchmarking, then skip ahead to the [Freestanding CLI](#freestanding-cli).
|
||||
|
||||
# Node Integrated CLI
|
||||
|
||||
@@ -32,7 +32,7 @@ SUBCOMMANDS:
|
||||
block Benchmark the execution time of historic blocks
|
||||
machine Command to benchmark the hardware.
|
||||
overhead Benchmark the execution overhead per-block and per-extrinsic
|
||||
pallet Benchmark the extrinsic weight of FRAME Pallets
|
||||
pezpallet Benchmark the extrinsic weight of FRAME Pallets
|
||||
storage Benchmark the storage speed of a chain snapshot
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ comparable.
|
||||
|
||||
The freestanding is a standalone CLI that does not rely on any node integration. It can be used to benchmark pallets of
|
||||
any FRAME runtime that does not utilize 3rd party host functions.
|
||||
It currently only supports pallet benchmarking, since the other commands still rely on a node.
|
||||
It currently only supports pezpallet benchmarking, since the other commands still rely on a node.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -57,7 +57,7 @@ cargo install --locked --path bizinikiwi/utils/pezframe/omni-bencher --profile=p
|
||||
|
||||
## Usage
|
||||
|
||||
The exposed pallet sub-command is identical as the node-integrated CLI. The only difference is that it needs to be prefixed
|
||||
The exposed pezpallet sub-command is identical as the node-integrated CLI. The only difference is that it needs to be prefixed
|
||||
with a `v1` to ensure drop-in compatibility.
|
||||
|
||||
First we need to ensure that there is a runtime available. As example we will build the zagros runtime:
|
||||
@@ -70,12 +70,12 @@ Now the benchmarking can be started with:
|
||||
|
||||
```sh
|
||||
frame-omni-bencher v1 \
|
||||
benchmark pallet \
|
||||
benchmark pezpallet \
|
||||
--runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
--pallet "pallet_balances" --extrinsic ""
|
||||
--pezpallet "pallet_balances" --extrinsic ""
|
||||
```
|
||||
|
||||
For the exact arguments of the `pallet` command, please refer to the [pallet] sub-module.
|
||||
For the exact arguments of the `pezpallet` command, please refer to the [pezpallet] sub-module.
|
||||
|
||||
# Commands
|
||||
|
||||
@@ -84,14 +84,14 @@ The sub-commands of both CLIs have the same semantics and are documented in thei
|
||||
- [block] Compare the weight of a historic block to its actual resource usage
|
||||
- [machine] Gauges the speed of the hardware
|
||||
- [overhead] Creates weight files for the *Block*- and *Extrinsic*-base weights
|
||||
- [pallet] Creates weight files for a Pallet
|
||||
- [pezpallet] Creates weight files for a Pezpallet
|
||||
- [storage] Creates weight files for *Read* and *Write* storage operations
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
<!-- LINKS -->
|
||||
|
||||
[pallet]: ../../../frame/benchmarking/README.md
|
||||
[pezpallet]: ../../../frame/benchmarking/README.md
|
||||
[machine]: src/machine/README.md
|
||||
[storage]: src/storage/README.md
|
||||
[overhead]: src/overhead/README.md
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The whole benchmarking process in Bizinikiwi aims to predict the resource usage of an unexecuted block. This command
|
||||
measures how accurate this prediction was by executing a block and comparing the predicted weight to its actual resource
|
||||
usage. It can be used to measure the accuracy of the pallet benchmarking.
|
||||
usage. It can be used to measure the accuracy of the pezpallet benchmarking.
|
||||
|
||||
In the following it will be explained once for PezkuwiChain and once for Bizinikiwi.
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ pub struct ExtrinsicParams {
|
||||
|
||||
/// List all available pallets and extrinsics.
|
||||
///
|
||||
/// The format is CSV with header `pallet, extrinsic`.
|
||||
/// The format is CSV with header `pezpallet, extrinsic`.
|
||||
#[arg(long)]
|
||||
pub list: bool,
|
||||
|
||||
/// Pallet name of the extrinsic to benchmark.
|
||||
#[arg(long, value_name = "PALLET", required_unless_present = "list")]
|
||||
pub pallet: Option<String>,
|
||||
/// Pezpallet name of the extrinsic to benchmark.
|
||||
#[arg(long, value_name = "PEZPALLET", required_unless_present = "list")]
|
||||
pub pezpallet: Option<String>,
|
||||
|
||||
/// Extrinsic to benchmark.
|
||||
#[arg(long, value_name = "EXTRINSIC", required_unless_present = "list")]
|
||||
@@ -110,12 +110,12 @@ impl ExtrinsicCmd {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let pallet = self.params.pallet.clone().unwrap_or_default();
|
||||
let pezpallet = self.params.pezpallet.clone().unwrap_or_default();
|
||||
let extrinsic = self.params.extrinsic.clone().unwrap_or_default();
|
||||
let ext_builder = match ext_factory.try_get(&pallet, &extrinsic) {
|
||||
let ext_builder = match ext_factory.try_get(&pezpallet, &extrinsic) {
|
||||
Some(ext_builder) => ext_builder,
|
||||
None =>
|
||||
return Err("Unknown pallet or extrinsic. Use --list for a complete list.".into()),
|
||||
return Err("Unknown pezpallet or extrinsic. Use --list for a complete list.".into()),
|
||||
};
|
||||
|
||||
let bench =
|
||||
@@ -123,7 +123,7 @@ impl ExtrinsicCmd {
|
||||
let stats = bench.bench_extrinsic(ext_builder)?;
|
||||
info!(
|
||||
"Executing a {}::{} extrinsic takes[ns]:\n{:?}",
|
||||
ext_builder.pallet(),
|
||||
ext_builder.pezpallet(),
|
||||
ext_builder.extrinsic(),
|
||||
stats
|
||||
);
|
||||
|
||||
@@ -25,16 +25,16 @@ use pezsp_runtime::OpaqueExtrinsic;
|
||||
pub struct ExtrinsicFactory(pub Vec<Box<dyn ExtrinsicBuilder>>);
|
||||
|
||||
impl ExtrinsicFactory {
|
||||
/// Returns a builder for a pallet and extrinsic name.
|
||||
/// Returns a builder for a pezpallet and extrinsic name.
|
||||
///
|
||||
/// Is case in-sensitive.
|
||||
pub fn try_get(&self, pallet: &str, extrinsic: &str) -> Option<&dyn ExtrinsicBuilder> {
|
||||
let pallet = pallet.to_lowercase();
|
||||
pub fn try_get(&self, pezpallet: &str, extrinsic: &str) -> Option<&dyn ExtrinsicBuilder> {
|
||||
let pezpallet = pezpallet.to_lowercase();
|
||||
let extrinsic = extrinsic.to_lowercase();
|
||||
|
||||
self.0
|
||||
.iter()
|
||||
.find(|b| b.pallet() == pallet && b.extrinsic() == extrinsic)
|
||||
.find(|b| b.pezpallet() == pezpallet && b.extrinsic() == extrinsic)
|
||||
.map(|b| b.as_ref())
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,10 @@ impl ExtrinsicFactory {
|
||||
/// This assumption simplifies the generation of the extrinsics.
|
||||
/// The signer should be one of the pre-funded dev accounts.
|
||||
pub trait ExtrinsicBuilder {
|
||||
/// Name of the pallet this builder is for.
|
||||
/// Name of the pezpallet this builder is for.
|
||||
///
|
||||
/// Should be all lowercase.
|
||||
fn pallet(&self) -> &str;
|
||||
fn pezpallet(&self) -> &str;
|
||||
|
||||
/// Name of the extrinsic this builder is for.
|
||||
///
|
||||
@@ -63,8 +63,8 @@ pub trait ExtrinsicBuilder {
|
||||
}
|
||||
|
||||
impl dyn ExtrinsicBuilder + '_ {
|
||||
/// Name of this builder in CSV format: `pallet, extrinsic`.
|
||||
/// Name of this builder in CSV format: `pezpallet, extrinsic`.
|
||||
pub fn name(&self) -> String {
|
||||
format!("{}, {}", self.pallet(), self.extrinsic())
|
||||
format!("{}, {}", self.pezpallet(), self.extrinsic())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ mod block;
|
||||
mod extrinsic;
|
||||
mod machine;
|
||||
mod overhead;
|
||||
mod pallet;
|
||||
mod pezpallet;
|
||||
mod shared;
|
||||
mod storage;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub use overhead::{
|
||||
remark_builder::{DynamicRemarkBuilder, BizinikiwiRemarkBuilder},
|
||||
OpaqueBlock, OverheadCmd,
|
||||
};
|
||||
pub use pallet::PalletCmd;
|
||||
pub use pezpallet::PalletCmd;
|
||||
pub use pezsc_service::BasePath;
|
||||
pub use storage::StorageCmd;
|
||||
|
||||
@@ -43,7 +43,7 @@ use pezsc_cli::{CliConfiguration, DatabaseParams, ImportParams, PruningParams, R
|
||||
/// Has no effect itself besides printing a help menu of the sub-commands.
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum BenchmarkCmd {
|
||||
Pallet(PalletCmd),
|
||||
Pezpallet(PalletCmd),
|
||||
Storage(StorageCmd),
|
||||
Overhead(OverheadCmd),
|
||||
Block(BlockCmd),
|
||||
@@ -59,7 +59,7 @@ macro_rules! unwrap_cmd {
|
||||
$code:expr
|
||||
} => {
|
||||
match $self {
|
||||
BenchmarkCmd::Pallet($cmd) => $code,
|
||||
BenchmarkCmd::Pezpallet($cmd) => $code,
|
||||
BenchmarkCmd::Storage($cmd) => $code,
|
||||
BenchmarkCmd::Overhead($cmd) => $code,
|
||||
BenchmarkCmd::Block($cmd) => $code,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# The `benchmark overhead` command
|
||||
|
||||
Each time an extrinsic or a block is executed, a fixed weight is charged as "execution overhead". This is necessary
|
||||
since the weight that is calculated by the pallet benchmarks does not include this overhead. The exact overhead to can
|
||||
since the weight that is calculated by the pezpallet benchmarks does not include this overhead. The exact overhead to can
|
||||
vary per Bizinikiwi chain and needs to be calculated per chain. This command calculates the exact values of these
|
||||
overhead weights for any Bizinikiwi chain that supports it.
|
||||
|
||||
|
||||
@@ -236,8 +236,8 @@ fn create_inherent_data<Client: UsageProvider<Block> + HeaderBackend<Block>, Blo
|
||||
|
||||
/// Identifies what kind of chain we are dealing with.
|
||||
///
|
||||
/// Chains containing the `TeyrchainSystem` and `TeyrchainInfo` pallet are considered teyrchains.
|
||||
/// Chains containing the `ParaInherent` pallet are considered relay chains.
|
||||
/// Chains containing the `TeyrchainSystem` and `TeyrchainInfo` pezpallet are considered teyrchains.
|
||||
/// Chains containing the `ParaInherent` pezpallet are considered relay chains.
|
||||
fn identify_chain(metadata: &Metadata, para_id: Option<u32>) -> ChainType {
|
||||
let teyrchain_info_exists = metadata.pallet_by_name("TeyrchainInfo").is_some();
|
||||
let teyrchain_system_exists = metadata.pallet_by_name("TeyrchainSystem").is_some();
|
||||
@@ -548,7 +548,7 @@ impl OverheadCmd {
|
||||
+ pezsp_blockchain::HeaderBackend<Block>,
|
||||
C::Api: ApiExt<Block> + BlockBuilderApi<Block>,
|
||||
{
|
||||
if ext_builder.pallet() != "system" || ext_builder.extrinsic() != "remark" {
|
||||
if ext_builder.pezpallet() != "system" || ext_builder.extrinsic() != "remark" {
|
||||
return Err(format!("The extrinsic builder is required to build `System::Remark` extrinsics but builds `{}` extrinsics instead", ext_builder.name()).into());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,15 @@ use pezsp_runtime::{traits::Block as BlockT, OpaqueExtrinsic};
|
||||
use std::sync::Arc;
|
||||
use subxt::{
|
||||
client::RuntimeVersion as SubxtRuntimeVersion,
|
||||
config::{bizinikiwi::BizinikiwiExtrinsicParamsBuilder, HashFor},
|
||||
Config, OfflineClient, BizinikiwiConfig,
|
||||
config::{substrate::SubstrateExtrinsicParamsBuilder, HashFor},
|
||||
Config, OfflineClient, SubstrateConfig,
|
||||
};
|
||||
|
||||
/// Bizinikiwi configuration - based on SubstrateConfig
|
||||
pub type BizinikiwiConfig = SubstrateConfig;
|
||||
/// Bizinikiwi extrinsic params builder - based on SubstrateExtrinsicParamsBuilder
|
||||
pub type BizinikiwiExtrinsicParamsBuilder = SubstrateExtrinsicParamsBuilder<BizinikiwiConfig>;
|
||||
|
||||
pub type BizinikiwiRemarkBuilder = DynamicRemarkBuilder<BizinikiwiConfig>;
|
||||
|
||||
/// Remark builder that can be used to build simple extrinsics for
|
||||
@@ -98,7 +103,7 @@ impl<C: Config> DynamicRemarkBuilder<C> {
|
||||
}
|
||||
|
||||
impl ExtrinsicBuilder for DynamicRemarkBuilder<BizinikiwiConfig> {
|
||||
fn pallet(&self) -> &str {
|
||||
fn pezpallet(&self) -> &str {
|
||||
"system"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
The pallet command is explained in [frame/benchmarking](../../../../../frame/benchmarking/README.md).
|
||||
|
||||
License: Apache-2.0
|
||||
@@ -0,0 +1,3 @@
|
||||
The pezpallet command is explained in [frame/benchmarking](../../../../../frame/benchmarking/README.md).
|
||||
|
||||
License: Apache-2.0
|
||||
+83
-83
@@ -20,7 +20,7 @@ use super::{
|
||||
writer, ListOutput, PalletCmd, LOG_TARGET,
|
||||
};
|
||||
use crate::{
|
||||
pallet::{types::FetchedCode, GenesisBuilderPolicy},
|
||||
pezpallet::{types::FetchedCode, GenesisBuilderPolicy},
|
||||
shared::{
|
||||
genesis_state,
|
||||
genesis_state::{GenesisStateHandler, SpecGenesisSource, WARN_SPEC_GENESIS_CTOR},
|
||||
@@ -72,7 +72,7 @@ type BizinikiwiAndExtraHF<T> = (
|
||||
pub enum PovEstimationMode {
|
||||
/// Use the maximal encoded length as provided by [`codec::MaxEncodedLen`].
|
||||
MaxEncodedLen,
|
||||
/// Measure the accessed value size in the pallet benchmarking and add some trie overhead.
|
||||
/// Measure the accessed value size in the pezpallet benchmarking and add some trie overhead.
|
||||
Measured,
|
||||
/// Do not estimate the PoV size for this storage item or benchmark.
|
||||
Ignored,
|
||||
@@ -91,20 +91,20 @@ impl FromStr for PovEstimationMode {
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps (pallet, benchmark) -> ((pallet, storage) -> PovEstimationMode)
|
||||
/// Maps (pezpallet, benchmark) -> ((pezpallet, storage) -> PovEstimationMode)
|
||||
pub(crate) type PovModesMap =
|
||||
HashMap<(String, String), HashMap<(String, String), PovEstimationMode>>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct SelectedBenchmark {
|
||||
pallet: String,
|
||||
pezpallet: String,
|
||||
instance: String,
|
||||
extrinsic: String,
|
||||
components: Vec<(BenchmarkParameter, u32, u32)>,
|
||||
pov_modes: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
// This takes multiple benchmark batches and combines all the results where the pallet, instance,
|
||||
// This takes multiple benchmark batches and combines all the results where the pezpallet, instance,
|
||||
// and benchmark are the same.
|
||||
fn combine_batches(
|
||||
time_batches: Vec<BenchmarkBatch>,
|
||||
@@ -119,9 +119,9 @@ fn combine_batches(
|
||||
|
||||
db_batches
|
||||
.into_iter()
|
||||
.for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| {
|
||||
.for_each(|BenchmarkBatch { pezpallet, instance, benchmark, results }| {
|
||||
// We use this key to uniquely identify a benchmark among batches.
|
||||
let key = (pallet, instance, benchmark);
|
||||
let key = (pezpallet, instance, benchmark);
|
||||
|
||||
match all_benchmarks.get_mut(&key) {
|
||||
// We already have this benchmark, so we extend the results.
|
||||
@@ -135,9 +135,9 @@ fn combine_batches(
|
||||
|
||||
time_batches
|
||||
.into_iter()
|
||||
.for_each(|BenchmarkBatch { pallet, instance, benchmark, results }| {
|
||||
.for_each(|BenchmarkBatch { pezpallet, instance, benchmark, results }| {
|
||||
// We use this key to uniquely identify a benchmark among batches.
|
||||
let key = (pallet, instance, benchmark);
|
||||
let key = (pezpallet, instance, benchmark);
|
||||
|
||||
match all_benchmarks.get_mut(&key) {
|
||||
// We already have this benchmark, so we extend the results.
|
||||
@@ -148,8 +148,8 @@ fn combine_batches(
|
||||
|
||||
all_benchmarks
|
||||
.into_iter()
|
||||
.map(|((pallet, instance, benchmark), (time_results, db_results))| {
|
||||
BenchmarkBatchSplitResults { pallet, instance, benchmark, time_results, db_results }
|
||||
.map(|((pezpallet, instance, benchmark), (time_results, db_results))| {
|
||||
BenchmarkBatchSplitResults { pezpallet, instance, benchmark, time_results, db_results }
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
@@ -216,7 +216,7 @@ impl PalletCmd {
|
||||
Err("Neither a runtime nor a chain-spec were specified".to_string().into())
|
||||
}
|
||||
|
||||
/// Runs the pallet benchmarking command.
|
||||
/// Runs the pezpallet benchmarking command.
|
||||
pub fn run_with_spec<Hasher, ExtraHostFunctions>(
|
||||
&self,
|
||||
chain_spec: Option<Box<dyn ChainSpec>>,
|
||||
@@ -351,18 +351,18 @@ impl PalletCmd {
|
||||
let mut batches = Vec::new();
|
||||
let mut batches_db = Vec::new();
|
||||
let mut timer = time::SystemTime::now();
|
||||
// Maps (pallet, extrinsic) to its component ranges.
|
||||
// Maps (pezpallet, extrinsic) to its component ranges.
|
||||
let mut component_ranges = HashMap::<(String, String), Vec<ComponentRange>>::new();
|
||||
let pov_modes =
|
||||
Self::parse_pov_modes(&benchmarks_to_run, &storage_info, self.ignore_unknown_pov_mode)?;
|
||||
let mut failed = Vec::<(String, String)>::new();
|
||||
|
||||
'outer: for (i, SelectedBenchmark { pallet, instance, extrinsic, components, .. }) in
|
||||
'outer: for (i, SelectedBenchmark { pezpallet, instance, extrinsic, components, .. }) in
|
||||
benchmarks_to_run.clone().into_iter().enumerate()
|
||||
{
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"[{: >3} % ] Starting benchmark: {pallet}::{extrinsic}",
|
||||
"[{: >3} % ] Starting benchmark: {pezpallet}::{extrinsic}",
|
||||
(i * 100) / benchmarks_to_run.len(),
|
||||
);
|
||||
let all_components = if components.is_empty() {
|
||||
@@ -405,7 +405,7 @@ impl PalletCmd {
|
||||
}
|
||||
|
||||
component_ranges
|
||||
.entry((pallet.clone(), extrinsic.clone()))
|
||||
.entry((pezpallet.clone(), extrinsic.clone()))
|
||||
.or_default()
|
||||
.push(ComponentRange { name: name.to_string(), min: lowest, max: highest });
|
||||
}
|
||||
@@ -416,7 +416,7 @@ impl PalletCmd {
|
||||
let params = |verify: bool, repeats: u32| -> Vec<u8> {
|
||||
if benchmark_api_version >= 2 {
|
||||
(
|
||||
pallet.as_bytes(),
|
||||
pezpallet.as_bytes(),
|
||||
instance.as_bytes(),
|
||||
extrinsic.as_bytes(),
|
||||
&selected_components.clone(),
|
||||
@@ -426,7 +426,7 @@ impl PalletCmd {
|
||||
.encode()
|
||||
} else {
|
||||
(
|
||||
pallet.as_bytes(),
|
||||
pezpallet.as_bytes(),
|
||||
extrinsic.as_bytes(),
|
||||
&selected_components.clone(),
|
||||
verify,
|
||||
@@ -458,13 +458,13 @@ impl PalletCmd {
|
||||
"dispatch a benchmark",
|
||||
) {
|
||||
Err(e) => {
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pallet.clone(), extrinsic.clone()));
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pezpallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pezpallet.clone(), extrinsic.clone()));
|
||||
continue 'outer;
|
||||
},
|
||||
Ok(Err(e)) => {
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pallet.clone(), extrinsic.clone()));
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pezpallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pezpallet.clone(), extrinsic.clone()));
|
||||
continue 'outer;
|
||||
},
|
||||
Ok(Ok(b)) => b,
|
||||
@@ -491,13 +491,13 @@ impl PalletCmd {
|
||||
"dispatch a benchmark",
|
||||
) {
|
||||
Err(e) => {
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pallet.clone(), extrinsic.clone()));
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pezpallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pezpallet.clone(), extrinsic.clone()));
|
||||
continue 'outer;
|
||||
},
|
||||
Ok(Err(e)) => {
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pallet.clone(), extrinsic.clone()));
|
||||
log::error!(target: LOG_TARGET, "Benchmark {pezpallet}::{extrinsic} failed: {e}");
|
||||
failed.push((pezpallet.clone(), extrinsic.clone()));
|
||||
continue 'outer;
|
||||
},
|
||||
Ok(Ok(b)) => b,
|
||||
@@ -527,12 +527,12 @@ impl PalletCmd {
|
||||
) {
|
||||
Err(e) => {
|
||||
return Err(
|
||||
format!("Benchmark {pallet}::{extrinsic} failed: {e}").into()
|
||||
format!("Benchmark {pezpallet}::{extrinsic} failed: {e}").into()
|
||||
);
|
||||
},
|
||||
Ok(Err(e)) => {
|
||||
return Err(
|
||||
format!("Benchmark {pallet}::{extrinsic} failed: {e}").into()
|
||||
format!("Benchmark {pezpallet}::{extrinsic} failed: {e}").into()
|
||||
);
|
||||
},
|
||||
Ok(Ok(b)) => b,
|
||||
@@ -547,7 +547,7 @@ impl PalletCmd {
|
||||
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"[{: >3} % ] Running benchmark: {pallet}::{extrinsic}({} args) {}/{} {}/{}",
|
||||
"[{: >3} % ] Running benchmark: {pezpallet}::{extrinsic}({} args) {}/{} {}/{}",
|
||||
(i * 100) / benchmarks_to_run.len(),
|
||||
components.len(),
|
||||
s + 1, // s starts at 0.
|
||||
@@ -573,7 +573,7 @@ impl PalletCmd {
|
||||
return Err(format!("{} benchmarks failed", failed.len()).into());
|
||||
}
|
||||
|
||||
// Combine all of the benchmark results, so that benchmarks of the same pallet/function
|
||||
// Combine all of the benchmark results, so that benchmarks of the same pezpallet/function
|
||||
// are together.
|
||||
let batches = combine_batches(batches, batches_db);
|
||||
self.output(&batches, &storage_info, &component_ranges, pov_modes)
|
||||
@@ -582,11 +582,11 @@ impl PalletCmd {
|
||||
fn select_benchmarks_to_run(&self, list: Vec<BenchmarkList>) -> Result<Vec<SelectedBenchmark>> {
|
||||
// Use the benchmark list and the user input to determine the set of benchmarks to run.
|
||||
let mut benchmarks_to_run = Vec::new();
|
||||
list.iter().filter(|item| self.pezpallet_selected(&item.pallet)).for_each(|item| {
|
||||
list.iter().filter(|item| self.pezpallet_selected(&item.pezpallet)).for_each(|item| {
|
||||
for benchmark in &item.benchmarks {
|
||||
if self.extrinsic_selected(&item.pallet, &benchmark.name) {
|
||||
if self.extrinsic_selected(&item.pezpallet, &benchmark.name) {
|
||||
benchmarks_to_run.push((
|
||||
item.pallet.clone(),
|
||||
item.pezpallet.clone(),
|
||||
item.instance.clone(),
|
||||
benchmark.name.clone(),
|
||||
benchmark.components.clone(),
|
||||
@@ -598,14 +598,14 @@ impl PalletCmd {
|
||||
// Convert `Vec<u8>` to `String` for better readability.
|
||||
let benchmarks_to_run: Vec<_> = benchmarks_to_run
|
||||
.into_iter()
|
||||
.map(|(pallet, instance, extrinsic, components, pov_modes)| {
|
||||
let pallet = String::from_utf8(pallet).expect("Encoded from String; qed");
|
||||
.map(|(pezpallet, instance, extrinsic, components, pov_modes)| {
|
||||
let pezpallet = String::from_utf8(pezpallet).expect("Encoded from String; qed");
|
||||
let instance = String::from_utf8(instance).expect("Encoded from String; qed");
|
||||
let extrinsic =
|
||||
String::from_utf8(extrinsic.clone()).expect("Encoded from String; qed");
|
||||
|
||||
SelectedBenchmark {
|
||||
pallet,
|
||||
pezpallet,
|
||||
instance,
|
||||
extrinsic,
|
||||
components,
|
||||
@@ -620,28 +620,28 @@ impl PalletCmd {
|
||||
.collect();
|
||||
|
||||
if benchmarks_to_run.is_empty() {
|
||||
return Err("No benchmarks found which match your input. Try `--list --all` to list all available benchmarks. Make sure pallet is in `define_benchmarks!`".into());
|
||||
return Err("No benchmarks found which match your input. Try `--list --all` to list all available benchmarks. Make sure pezpallet is in `define_benchmarks!`".into());
|
||||
}
|
||||
|
||||
Ok(benchmarks_to_run)
|
||||
}
|
||||
|
||||
/// Whether this pallet should be run.
|
||||
fn pezpallet_selected(&self, pallet: &Vec<u8>) -> bool {
|
||||
/// Whether this pezpallet should be run.
|
||||
fn pezpallet_selected(&self, pezpallet: &Vec<u8>) -> bool {
|
||||
let include = self.pallets.clone();
|
||||
|
||||
let included = include.is_empty() ||
|
||||
include.iter().any(|p| p.as_bytes() == pallet) ||
|
||||
include.iter().any(|p| p.as_bytes() == pezpallet) ||
|
||||
include.iter().any(|p| p == "*") ||
|
||||
include.iter().any(|p| p == "all");
|
||||
let excluded = self.exclude_pallets.iter().any(|p| p.as_bytes() == pallet);
|
||||
let excluded = self.exclude_pallets.iter().any(|p| p.as_bytes() == pezpallet);
|
||||
|
||||
included && !excluded
|
||||
}
|
||||
|
||||
/// Whether this extrinsic should be run.
|
||||
fn extrinsic_selected(&self, pallet: &Vec<u8>, extrinsic: &Vec<u8>) -> bool {
|
||||
if !self.pezpallet_selected(pallet) {
|
||||
fn extrinsic_selected(&self, pezpallet: &Vec<u8>, extrinsic: &Vec<u8>) -> bool {
|
||||
if !self.pezpallet_selected(pezpallet) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -657,19 +657,19 @@ impl PalletCmd {
|
||||
let excluded = self
|
||||
.excluded_extrinsics()
|
||||
.iter()
|
||||
.any(|(p, e)| p.as_bytes() == pallet && e.as_bytes() == extrinsic);
|
||||
.any(|(p, e)| p.as_bytes() == pezpallet && e.as_bytes() == extrinsic);
|
||||
|
||||
included && !excluded
|
||||
}
|
||||
|
||||
/// All `(pallet, extrinsic)` tuples that are excluded from the benchmarks.
|
||||
/// All `(pezpallet, extrinsic)` tuples that are excluded from the benchmarks.
|
||||
fn excluded_extrinsics(&self) -> Vec<(String, String)> {
|
||||
let mut excluded = Vec::new();
|
||||
|
||||
for e in &self.exclude_extrinsics {
|
||||
let splits = e.split("::").collect::<Vec<_>>();
|
||||
if splits.len() != 2 {
|
||||
panic!("Invalid argument for '--exclude-extrinsics'. Expected format: 'pallet::extrinsic' but got '{}'", e);
|
||||
panic!("Invalid argument for '--exclude-extrinsics'. Expected format: 'pezpallet::extrinsic' but got '{}'", e);
|
||||
}
|
||||
excluded.push((splits[0].to_string(), splits[1].to_string()));
|
||||
}
|
||||
@@ -690,7 +690,7 @@ impl PalletCmd {
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Build the extension that are available for pallet benchmarks.
|
||||
/// Build the extension that are available for pezpallet benchmarks.
|
||||
fn build_extensions<E: CodeExecutor, H: Hasher + 'static>(
|
||||
exe: E,
|
||||
maybe_recorder: Option<Recorder<H>>,
|
||||
@@ -739,7 +739,7 @@ impl PalletCmd {
|
||||
}
|
||||
}
|
||||
|
||||
/// Allocation strategy for pallet benchmarking.
|
||||
/// Allocation strategy for pezpallet benchmarking.
|
||||
fn alloc_strategy(&self, runtime_heap_pages: Option<u64>) -> HeapAllocStrategy {
|
||||
self.heap_pages.or(runtime_heap_pages).map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |p| {
|
||||
HeapAllocStrategy::Static { extra_pages: p as _ }
|
||||
@@ -781,7 +781,7 @@ impl PalletCmd {
|
||||
for batch in batches {
|
||||
let range = component_ranges
|
||||
.entry((
|
||||
String::from_utf8(batch.pallet.clone()).unwrap(),
|
||||
String::from_utf8(batch.pezpallet.clone()).unwrap(),
|
||||
String::from_utf8(batch.benchmark.clone()).unwrap(),
|
||||
))
|
||||
.or_default();
|
||||
@@ -841,12 +841,12 @@ impl PalletCmd {
|
||||
) {
|
||||
for batch in batches.iter() {
|
||||
// Print benchmark metadata
|
||||
let pallet = String::from_utf8(batch.pallet.clone()).expect("Encoded from String; qed");
|
||||
let pezpallet = String::from_utf8(batch.pezpallet.clone()).expect("Encoded from String; qed");
|
||||
let benchmark =
|
||||
String::from_utf8(batch.benchmark.clone()).expect("Encoded from String; qed");
|
||||
println!(
|
||||
"Pallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}",
|
||||
pallet,
|
||||
"Pezpallet: {:?}, Extrinsic: {:?}, Lowest values: {:?}, Highest values: {:?}, Steps: {:?}, Repeat: {:?}",
|
||||
pezpallet,
|
||||
benchmark,
|
||||
self.lowest_range_values,
|
||||
self.highest_range_values,
|
||||
@@ -861,7 +861,7 @@ impl PalletCmd {
|
||||
|
||||
if !self.no_storage_info {
|
||||
let mut storage_per_prefix = HashMap::<Vec<u8>, Vec<BenchmarkResult>>::new();
|
||||
let pov_mode = pov_modes.get(&(pallet, benchmark)).cloned().unwrap_or_default();
|
||||
let pov_mode = pov_modes.get(&(pezpallet, benchmark)).cloned().unwrap_or_default();
|
||||
|
||||
let comments = writer::process_storage_results(
|
||||
&mut storage_per_prefix,
|
||||
@@ -940,7 +940,7 @@ impl PalletCmd {
|
||||
use std::collections::hash_map::Entry;
|
||||
let mut parsed = PovModesMap::new();
|
||||
|
||||
for SelectedBenchmark { pallet, extrinsic, pov_modes, .. } in benchmarks {
|
||||
for SelectedBenchmark { pezpallet, extrinsic, pov_modes, .. } in benchmarks {
|
||||
for (pezpallet_storage, mode) in pov_modes {
|
||||
let mode = PovEstimationMode::from_str(&mode)?;
|
||||
let pezpallet_storage = pezpallet_storage.replace(" ", "");
|
||||
@@ -948,7 +948,7 @@ impl PalletCmd {
|
||||
|
||||
if splits.is_empty() || splits.len() > 2 {
|
||||
return Err(format!(
|
||||
"Expected 'Pallet::Storage' as storage name but got: {}",
|
||||
"Expected 'Pezpallet::Storage' as storage name but got: {}",
|
||||
pezpallet_storage
|
||||
)
|
||||
.into());
|
||||
@@ -957,7 +957,7 @@ impl PalletCmd {
|
||||
(splits[0].trim(), splits.get(1).unwrap_or(&"ALL").trim());
|
||||
|
||||
match parsed
|
||||
.entry((pallet.clone(), extrinsic.clone()))
|
||||
.entry((pezpallet.clone(), extrinsic.clone()))
|
||||
.or_default()
|
||||
.entry((pov_pallet.to_string(), pov_storage.to_string()))
|
||||
{
|
||||
@@ -984,12 +984,12 @@ impl PalletCmd {
|
||||
storage_info: &[StorageInfo],
|
||||
ignore_unknown_pov_mode: bool,
|
||||
) -> Result<()> {
|
||||
// Check that all PoV modes are valid pallet storage keys
|
||||
for (pallet, storage) in pov_modes.values().flat_map(|i| i.keys()) {
|
||||
// Check that all PoV modes are valid pezpallet storage keys
|
||||
for (pezpallet, storage) in pov_modes.values().flat_map(|i| i.keys()) {
|
||||
let (mut found_pallet, mut found_storage) = (false, false);
|
||||
|
||||
for info in storage_info {
|
||||
if pallet == "ALL" || info.pezpallet_name == pallet.as_bytes() {
|
||||
if pezpallet == "ALL" || info.pezpallet_name == pezpallet.as_bytes() {
|
||||
found_pallet = true;
|
||||
}
|
||||
if storage == "ALL" || info.storage_name == storage.as_bytes() {
|
||||
@@ -997,7 +997,7 @@ impl PalletCmd {
|
||||
}
|
||||
}
|
||||
if !found_pallet || !found_storage {
|
||||
let err = format!("The PoV mode references an unknown storage item or pallet: `{}::{}`. You can ignore this warning by specifying `--ignore-unknown-pov-mode`", pallet, storage);
|
||||
let err = format!("The PoV mode references an unknown storage item or pezpallet: `{}::{}`. You can ignore this warning by specifying `--ignore-unknown-pov-mode`", pezpallet, storage);
|
||||
|
||||
if ignore_unknown_pov_mode {
|
||||
log::warn!(target: LOG_TARGET, "Error demoted to warning due to `--ignore-unknown-pov-mode`: {}", err);
|
||||
@@ -1091,10 +1091,10 @@ fn list_benchmark(
|
||||
) {
|
||||
let mut benchmarks = BTreeMap::new();
|
||||
|
||||
// Sort and de-dub by pallet and function name.
|
||||
// Sort and de-dub by pezpallet and function name.
|
||||
benchmarks_to_run.iter().for_each(|bench| {
|
||||
benchmarks
|
||||
.entry(&bench.pallet)
|
||||
.entry(&bench.pezpallet)
|
||||
.or_insert_with(BTreeSet::new)
|
||||
.insert(&bench.extrinsic);
|
||||
});
|
||||
@@ -1102,27 +1102,27 @@ fn list_benchmark(
|
||||
match list_output {
|
||||
ListOutput::All => {
|
||||
if !no_csv_header {
|
||||
println!("pallet, extrinsic");
|
||||
println!("pezpallet, extrinsic");
|
||||
}
|
||||
for (pallet, extrinsics) in benchmarks {
|
||||
for (pezpallet, extrinsics) in benchmarks {
|
||||
for extrinsic in extrinsics {
|
||||
println!("{pallet}, {extrinsic}");
|
||||
println!("{pezpallet}, {extrinsic}");
|
||||
}
|
||||
}
|
||||
},
|
||||
ListOutput::Pallets => {
|
||||
if !no_csv_header {
|
||||
println!("pallet");
|
||||
println!("pezpallet");
|
||||
};
|
||||
for pallet in benchmarks.keys() {
|
||||
println!("{pallet}");
|
||||
for pezpallet in benchmarks.keys() {
|
||||
println!("{pezpallet}");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::pallet::PalletCmd;
|
||||
use crate::pezpallet::PalletCmd;
|
||||
use clap::Parser;
|
||||
|
||||
fn cli_succeed(args: &[&str]) -> Result<(), clap::Error> {
|
||||
@@ -1145,7 +1145,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/runtime",
|
||||
@@ -1156,19 +1156,19 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/runtime",
|
||||
"--genesis-builder",
|
||||
"none",
|
||||
])?;
|
||||
cli_succeed(&["test", "--extrinsic", "", "--pallet", "", "--runtime", "path/to/runtime"])?;
|
||||
cli_succeed(&["test", "--extrinsic", "", "--pezpallet", "", "--runtime", "path/to/runtime"])?;
|
||||
cli_succeed(&[
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/runtime",
|
||||
@@ -1179,7 +1179,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/runtime",
|
||||
@@ -1190,7 +1190,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/spec",
|
||||
@@ -1201,7 +1201,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--runtime",
|
||||
"path/to/spec",
|
||||
@@ -1211,12 +1211,12 @@ mod tests {
|
||||
cli_fail(&["test", "--runtime", "path/to/spec", "--genesis-builder", "spec-genesis"]);
|
||||
|
||||
// Spec tests
|
||||
cli_succeed(&["test", "--extrinsic", "", "--pallet", "", "--chain", "path/to/spec"])?;
|
||||
cli_succeed(&["test", "--extrinsic", "", "--pezpallet", "", "--chain", "path/to/spec"])?;
|
||||
cli_succeed(&[
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
@@ -1227,7 +1227,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
@@ -1238,7 +1238,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
@@ -1249,7 +1249,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
@@ -1260,7 +1260,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
@@ -1271,7 +1271,7 @@ mod tests {
|
||||
"test",
|
||||
"--extrinsic",
|
||||
"",
|
||||
"--pallet",
|
||||
"--pezpallet",
|
||||
"",
|
||||
"--chain",
|
||||
"path/to/spec",
|
||||
+8
-8
@@ -30,12 +30,12 @@ use pezsc_cli::{
|
||||
use std::{fmt::Debug, path::PathBuf};
|
||||
|
||||
/// Logging target
|
||||
const LOG_TARGET: &'static str = "frame::benchmark::pallet";
|
||||
const LOG_TARGET: &'static str = "frame::benchmark::pezpallet";
|
||||
|
||||
// Add a more relaxed parsing for pallet names by allowing pallet directory names with `-` to be
|
||||
// Add a more relaxed parsing for pezpallet names by allowing pezpallet directory names with `-` to be
|
||||
// used like crate names with `_`
|
||||
fn parse_pallet_name(pallet: &str) -> std::result::Result<String, String> {
|
||||
Ok(pallet.replace("-", "_"))
|
||||
fn parse_pallet_name(pezpallet: &str) -> std::result::Result<String, String> {
|
||||
Ok(pezpallet.replace("-", "_"))
|
||||
}
|
||||
|
||||
/// List options for available benchmarks.
|
||||
@@ -52,10 +52,10 @@ pub enum ListOutput {
|
||||
pub struct PalletCmd {
|
||||
/// Select a FRAME Pallets to benchmark, or `*` for all (in which case `extrinsic` must be
|
||||
/// `*`).
|
||||
#[arg(short, long, alias = "pallet", num_args = 1.., value_delimiter = ',', value_parser = parse_pallet_name, required_unless_present_any = ["list", "json_input", "all"], default_value_if("all", "true", Some("*".into())))]
|
||||
#[arg(short, long, alias = "pezpallet", num_args = 1.., value_delimiter = ',', value_parser = parse_pallet_name, required_unless_present_any = ["list", "json_input", "all"], default_value_if("all", "true", Some("*".into())))]
|
||||
pub pallets: Vec<String>,
|
||||
|
||||
/// Select an extrinsic inside the pallet to benchmark, or `*` or 'all' for all.
|
||||
/// Select an extrinsic inside the pezpallet to benchmark, or `*` or 'all' for all.
|
||||
#[arg(short, long, required_unless_present_any = ["list", "json_input", "all"], default_value_if("all", "true", Some("*".into())))]
|
||||
pub extrinsic: Option<String>,
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct PalletCmd {
|
||||
#[arg(long, value_parser, num_args = 1.., value_delimiter = ',')]
|
||||
pub exclude_pallets: Vec<String>,
|
||||
|
||||
/// Comma separated list of `pallet::extrinsic` combinations that should not be run.
|
||||
/// Comma separated list of `pezpallet::extrinsic` combinations that should not be run.
|
||||
///
|
||||
/// Example: `pezframe_system::remark,pezpallet_balances::transfer_keep_alive`
|
||||
#[arg(long, value_parser, num_args = 1.., value_delimiter = ',')]
|
||||
@@ -71,7 +71,7 @@ pub struct PalletCmd {
|
||||
|
||||
/// Run benchmarks for all pallets and extrinsics.
|
||||
///
|
||||
/// This is equivalent to running `--pallet * --extrinsic *`.
|
||||
/// This is equivalent to running `--pezpallet * --extrinsic *`.
|
||||
#[arg(long)]
|
||||
pub all: bool,
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a (pallet, benchmark) to its component ranges.
|
||||
/// Maps a (pezpallet, benchmark) to its component ranges.
|
||||
pub(crate) type ComponentRangeMap =
|
||||
std::collections::HashMap<(String, String), Vec<ComponentRange>>;
|
||||
|
||||
+21
-21
@@ -28,7 +28,7 @@ use itertools::Itertools;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::{
|
||||
pallet::{
|
||||
pezpallet::{
|
||||
command::{PovEstimationMode, PovModesMap},
|
||||
types::{ComponentRange, ComponentRangeMap},
|
||||
},
|
||||
@@ -53,7 +53,7 @@ struct TemplateData {
|
||||
hostname: String,
|
||||
cpuname: String,
|
||||
version: String,
|
||||
pallet: String,
|
||||
pezpallet: String,
|
||||
instance: String,
|
||||
header: String,
|
||||
cmd: CmdData,
|
||||
@@ -124,7 +124,7 @@ fn io_error(s: &str) -> std::io::Error {
|
||||
Error::new(ErrorKind::Other, s)
|
||||
}
|
||||
|
||||
// This function takes a list of `BenchmarkBatch` and organizes them by pallet into a `HashMap`.
|
||||
// This function takes a list of `BenchmarkBatch` and organizes them by pezpallet into a `HashMap`.
|
||||
// So this: `[(p1, b1), (p1, b2), (p2, b1), (p1, b3), (p2, b2)]`
|
||||
// Becomes:
|
||||
//
|
||||
@@ -156,7 +156,7 @@ fn map_results(
|
||||
continue;
|
||||
}
|
||||
|
||||
let pezpallet_name = String::from_utf8(batch.pallet.clone()).unwrap();
|
||||
let pezpallet_name = String::from_utf8(batch.pezpallet.clone()).unwrap();
|
||||
let instance_name = String::from_utf8(batch.instance.clone()).unwrap();
|
||||
let benchmark_data = get_benchmark_data(
|
||||
batch,
|
||||
@@ -210,7 +210,7 @@ fn get_benchmark_data(
|
||||
AnalysisChoice::MedianSlopes => Analysis::median_slopes,
|
||||
AnalysisChoice::Max => Analysis::max,
|
||||
};
|
||||
let pallet = String::from_utf8(batch.pallet.clone()).unwrap();
|
||||
let pezpallet = String::from_utf8(batch.pezpallet.clone()).unwrap();
|
||||
let benchmark = String::from_utf8(batch.benchmark.clone()).unwrap();
|
||||
|
||||
let extrinsic_time = analysis_function(&batch.time_results, BenchmarkSelector::ExtrinsicTime)
|
||||
@@ -287,7 +287,7 @@ fn get_benchmark_data(
|
||||
// We add additional comments showing which storage items were touched.
|
||||
// We find the worst case proof size, and use that as the final proof size result.
|
||||
let mut storage_per_prefix = HashMap::<Vec<u8>, Vec<BenchmarkResult>>::new();
|
||||
let pov_mode = pov_modes.get(&(pallet.clone(), benchmark.clone())).cloned().unwrap_or_default();
|
||||
let pov_mode = pov_modes.get(&(pezpallet.clone(), benchmark.clone())).cloned().unwrap_or_default();
|
||||
let comments = process_storage_results(
|
||||
&mut storage_per_prefix,
|
||||
&batch.db_results,
|
||||
@@ -353,7 +353,7 @@ fn get_benchmark_data(
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let component_ranges = component_ranges
|
||||
.get(&(pallet.clone(), benchmark.clone()))
|
||||
.get(&(pezpallet.clone(), benchmark.clone()))
|
||||
.map(|c| c.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
@@ -441,7 +441,7 @@ pub(crate) fn write_results(
|
||||
// Don't HTML escape any characters.
|
||||
handlebars.register_escape_fn(|s| -> String { s.to_string() });
|
||||
|
||||
// Organize results by pallet into a JSON map
|
||||
// Organize results by pezpallet into a JSON map
|
||||
let all_results = map_results(
|
||||
batches,
|
||||
storage_info,
|
||||
@@ -455,20 +455,20 @@ pub(crate) fn write_results(
|
||||
)?;
|
||||
let mut created_files = Vec::new();
|
||||
|
||||
for ((pallet, instance), results) in all_results.iter() {
|
||||
for ((pezpallet, instance), results) in all_results.iter() {
|
||||
let mut file_path = path.clone();
|
||||
// If a user only specified a directory...
|
||||
if file_path.is_dir() {
|
||||
// Start with "path/to/pezpallet_name".
|
||||
let mut file_name = pallet.clone();
|
||||
let mut file_name = pezpallet.clone();
|
||||
// Check if there might be multiple instances benchmarked.
|
||||
if all_results.keys().any(|(p, i)| p == pallet && i != instance) {
|
||||
if all_results.keys().any(|(p, i)| p == pezpallet && i != instance) {
|
||||
// Append "_instance_name".
|
||||
file_name = format!("{}_{}", file_name, instance.to_snake_case());
|
||||
}
|
||||
// "mod::pezpallet_name.rs" becomes "mod_pallet_name.rs".
|
||||
file_name = file_name.replace("::", "_");
|
||||
// Some old runtimes have a bug with the pallet and instance name containing a space
|
||||
// Some old runtimes have a bug with the pezpallet and instance name containing a space
|
||||
file_name = file_name.replace(" ", "");
|
||||
file_path.push(file_name);
|
||||
file_path.set_extension("rs");
|
||||
@@ -480,7 +480,7 @@ pub(crate) fn write_results(
|
||||
hostname: cmd.hostinfo_params.hostname(),
|
||||
cpuname: cmd.hostinfo_params.cpuname(),
|
||||
version: VERSION.to_string(),
|
||||
pallet: pallet.to_string(),
|
||||
pezpallet: pezpallet.to_string(),
|
||||
instance: instance.to_string(),
|
||||
header: header_text.clone(),
|
||||
cmd: cmd_data.clone(),
|
||||
@@ -501,7 +501,7 @@ pub(crate) fn write_results(
|
||||
if !overwritten_files.is_empty() {
|
||||
let msg = format!(
|
||||
"Multiple results were written to the same file. This can happen when \
|
||||
there are multiple instances of a pallet deployed and `--output` forces the output of all \
|
||||
there are multiple instances of a pezpallet deployed and `--output` forces the output of all \
|
||||
instances into the same file. Use `--unsafe-overwrite-results` to ignore this error. The \
|
||||
affected files are: {:?}",
|
||||
overwritten_files
|
||||
@@ -835,7 +835,7 @@ mod test {
|
||||
use pezframe_benchmarking::{BenchmarkBatchSplitResults, BenchmarkParameter, BenchmarkResult};
|
||||
|
||||
fn test_data(
|
||||
pallet: &[u8],
|
||||
pezpallet: &[u8],
|
||||
benchmark: &[u8],
|
||||
param: BenchmarkParameter,
|
||||
base: u32,
|
||||
@@ -858,7 +858,7 @@ mod test {
|
||||
}
|
||||
|
||||
return BenchmarkBatchSplitResults {
|
||||
pallet: [pallet.to_vec(), b"_pallet".to_vec()].concat(),
|
||||
pezpallet: [pezpallet.to_vec(), b"_pallet".to_vec()].concat(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: [benchmark.to_vec(), b"_benchmark".to_vec()].concat(),
|
||||
time_results: results.clone(),
|
||||
@@ -937,7 +937,7 @@ mod test {
|
||||
}
|
||||
|
||||
let data = BenchmarkBatchSplitResults {
|
||||
pallet: b"scheduler".to_vec(),
|
||||
pezpallet: b"scheduler".to_vec(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: b"first_benchmark".to_vec(),
|
||||
time_results: results.clone(),
|
||||
@@ -994,7 +994,7 @@ mod test {
|
||||
}
|
||||
|
||||
let data = BenchmarkBatchSplitResults {
|
||||
pallet: b"scheduler".to_vec(),
|
||||
pezpallet: b"scheduler".to_vec(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: b"first_benchmark".to_vec(),
|
||||
time_results: results.clone(),
|
||||
@@ -1051,7 +1051,7 @@ mod test {
|
||||
}
|
||||
|
||||
let data = BenchmarkBatchSplitResults {
|
||||
pallet: b"scheduler".to_vec(),
|
||||
pezpallet: b"scheduler".to_vec(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: b"first_benchmark".to_vec(),
|
||||
time_results: results.clone(),
|
||||
@@ -1106,7 +1106,7 @@ mod test {
|
||||
}
|
||||
|
||||
let data = BenchmarkBatchSplitResults {
|
||||
pallet: b"scheduler".to_vec(),
|
||||
pezpallet: b"scheduler".to_vec(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: b"first_benchmark".to_vec(),
|
||||
time_results: results.clone(),
|
||||
@@ -1163,7 +1163,7 @@ mod test {
|
||||
}
|
||||
|
||||
let data = BenchmarkBatchSplitResults {
|
||||
pallet: b"scheduler".to_vec(),
|
||||
pezpallet: b"scheduler".to_vec(),
|
||||
instance: b"instance".to_vec(),
|
||||
benchmark: b"first_benchmark".to_vec(),
|
||||
time_results: results.clone(),
|
||||
@@ -1,7 +1,7 @@
|
||||
# PezkuwiChain Omni Benchmarking CLI
|
||||
|
||||
The PezkuwiChain Omni benchmarker allows to benchmark the extrinsics of any PezkuwiChain runtime. It is
|
||||
meant to replace the current manual integration of the `benchmark pallet` into every teyrchain node.
|
||||
meant to replace the current manual integration of the `benchmark pezpallet` into every teyrchain node.
|
||||
This reduces duplicate code and makes maintenance for builders easier. The CLI is currently only
|
||||
able to benchmark extrinsics. In the future it is planned to extend this to some other areas.
|
||||
|
||||
@@ -43,12 +43,12 @@ runtime:
|
||||
cargo build -p zagros-runtime --profile production --features runtime-benchmarks
|
||||
```
|
||||
|
||||
Now as an example, we benchmark the `balances` pallet:
|
||||
Now as an example, we benchmark the `balances` pezpallet:
|
||||
|
||||
```sh
|
||||
frame-omni-bencher v1 benchmark pallet \
|
||||
frame-omni-bencher v1 benchmark pezpallet \
|
||||
--runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
--pallet "pallet_balances" --extrinsic ""
|
||||
--pezpallet "pallet_balances" --extrinsic ""
|
||||
```
|
||||
|
||||
The `--steps`, `--repeat`, `--heap-pages` and `--wasm-execution` arguments have sane defaults and do
|
||||
@@ -60,18 +60,18 @@ To render Rust weight files from benchmark results, pass an output path. Optiona
|
||||
custom header and a Handlebars template (defaults are provided):
|
||||
|
||||
```sh
|
||||
frame-omni-bencher v1 benchmark pallet \
|
||||
frame-omni-bencher v1 benchmark pezpallet \
|
||||
--runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
--pallet "pallet_balances" --extrinsic "*" \
|
||||
--pezpallet "pallet_balances" --extrinsic "*" \
|
||||
--output ./weights/ \
|
||||
--header ./HEADER.rs \
|
||||
--template ./template.hbs
|
||||
```
|
||||
|
||||
This uses the same flags as the node-integrated benchmarking CLI. The output can be a directory or a
|
||||
file path; when a directory is given, a file name is generated per pallet/instance.
|
||||
file path; when a directory is given, a file name is generated per pezpallet/instance.
|
||||
|
||||
## Backwards Compatibility
|
||||
|
||||
The exposed pallet sub-command is identical as the node-integrated CLI. The only difference is that
|
||||
The exposed pezpallet sub-command is identical as the node-integrated CLI. The only difference is that
|
||||
it needs to be prefixed with a `v1` to ensure drop-in compatibility.
|
||||
|
||||
@@ -23,7 +23,7 @@ use pezsp_runtime::traits::BlakeTwo256;
|
||||
/// # Pezkuwi Omni Benchmarking CLI
|
||||
///
|
||||
/// The Pezkuwi Omni benchmarker allows to benchmark the extrinsics of any Pezkuwi runtime. It is
|
||||
/// meant to replace the current manual integration of the `benchmark pallet` into every teyrchain
|
||||
/// meant to replace the current manual integration of the `benchmark pezpallet` into every teyrchain
|
||||
/// node. This reduces duplicate code and makes maintenance for builders easier. The CLI is
|
||||
/// currently only able to benchmark extrinsics. In the future it is planned to extend this to some
|
||||
/// other areas.
|
||||
@@ -66,19 +66,19 @@ use pezsp_runtime::traits::BlakeTwo256;
|
||||
/// cargo build -p zagros-runtime --profile production --features runtime-benchmarks
|
||||
/// ```
|
||||
///
|
||||
/// Now as an example, we benchmark the `balances` pallet:
|
||||
/// Now as an example, we benchmark the `balances` pezpallet:
|
||||
///
|
||||
/// ```sh
|
||||
/// frame-omni-bencher v1 benchmark pallet \
|
||||
/// frame-omni-bencher v1 benchmark pezpallet \
|
||||
/// --runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
/// --pallet "pezpallet_balances" --extrinsic ""
|
||||
/// --pezpallet "pezpallet_balances" --extrinsic ""
|
||||
/// ```
|
||||
///
|
||||
/// For the exact arguments of the `pallet` command, please refer to the `pallet` sub-module.
|
||||
/// For the exact arguments of the `pezpallet` command, please refer to the `pezpallet` sub-module.
|
||||
///
|
||||
/// ## Backwards Compatibility
|
||||
///
|
||||
/// The exposed pallet sub-command is identical as the node-integrated CLI. The only difference is
|
||||
/// The exposed pezpallet sub-command is identical as the node-integrated CLI. The only difference is
|
||||
/// that it needs to be prefixed with a `v1` to ensure drop-in compatibility.
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, verbatim_doc_comment)]
|
||||
@@ -133,14 +133,14 @@ impl V1SubCommand {
|
||||
pub fn run(self) -> Result<()> {
|
||||
match self {
|
||||
V1SubCommand::Benchmark(V1BenchmarkCommand { sub }) => match sub {
|
||||
BenchmarkCmd::Pallet(pallet) => {
|
||||
pallet.run_with_spec::<BlakeTwo256, HostFunctions>(None)
|
||||
BenchmarkCmd::Pezpallet(pezpallet) => {
|
||||
pezpallet.run_with_spec::<BlakeTwo256, HostFunctions>(None)
|
||||
},
|
||||
BenchmarkCmd::Overhead(overhead_cmd) =>
|
||||
overhead_cmd.run_with_default_builder_and_spec::<OpaqueBlock, HostFunctions>(None),
|
||||
_ =>
|
||||
return Err(
|
||||
"Only the `v1 benchmark pallet` and `v1 benchmark overhead` command is currently supported".into()
|
||||
"Only the `v1 benchmark pezpallet` and `v1 benchmark overhead` command is currently supported".into()
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -86,27 +86,27 @@ use pezsp_storage::{StorageData, StorageKey};
|
||||
/// // Note that all fields are marked pub.
|
||||
/// pub use self::pezpallet_test::*;
|
||||
///
|
||||
/// #[pezframe_support::pallet]
|
||||
/// #[pezframe_support::pezpallet]
|
||||
/// mod pezpallet_test {
|
||||
/// use super::*;
|
||||
/// use pezframe_support::pezpallet_prelude::*;
|
||||
///
|
||||
/// #[pallet::pallet]
|
||||
/// pub struct Pallet<T>(_);
|
||||
/// #[pezpallet::pezpallet]
|
||||
/// pub struct Pezpallet<T>(_);
|
||||
///
|
||||
/// #[pallet::config]
|
||||
/// #[pezpallet::config]
|
||||
/// pub trait Config: pezframe_system::Config {}
|
||||
///
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type LastActionId<T> = StorageValue<_, u64, ValueQuery>;
|
||||
///
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Voxels<T> = StorageMap<_, Blake2_128Concat, Loc, Block>;
|
||||
///
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Actions<T> = StorageMap<_, Blake2_128Concat, u64, Loc>;
|
||||
///
|
||||
/// #[pallet::storage]
|
||||
/// #[pezpallet::storage]
|
||||
/// pub type Prefab<T> = StorageDoubleMap<
|
||||
/// _,
|
||||
/// Blake2_128Concat, u128,
|
||||
|
||||
Reference in New Issue
Block a user