-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup String::from_utf8 #3446
Conversation
@@ -329,12 +335,12 @@ impl PalletCmd { | |||
let mut component_ranges = HashMap::<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>::new(); | |||
let pov_modes = Self::parse_pov_modes(&benchmarks_to_run)?; | |||
|
|||
for (pallet, extrinsic, components, _) in benchmarks_to_run.clone() { | |||
for (pallet, extrinsic, components, _, pallet_str, extrinsic_str) in benchmarks_to_run.clone() { | |||
log::info!( | |||
target: LOG_TARGET, | |||
"Starting benchmark: {}::{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Starting benchmark: {}::{}", | |
"Starting benchmark: {pallet_str}::{extrinsic_str}", |
pallet_str, | ||
extrinsic_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pallet_str, | |
extrinsic_str, |
@@ -417,8 +423,8 @@ impl PalletCmd { | |||
.map_err(|e| { | |||
format!( | |||
"Benchmark {}::{} failed: {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Benchmark {}::{} failed: {}", | |
"Benchmark {pallet_str}::{extrinsic_str} failed: {e}", |
pallet_str, | ||
extrinsic_str, | ||
e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pallet_str, | |
extrinsic_str, | |
e |
@@ -495,10 +501,8 @@ impl PalletCmd { | |||
log::info!( | |||
target: LOG_TARGET, | |||
"Running benchmark: {}.{}({} args) {}/{} {}/{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Running benchmark: {}.{}({} args) {}/{} {}/{}", | |
"Running benchmark: {pallet_str}.{extrinsic_str}({} args) {}/{} {}/{}", |
pallet_str, | ||
extrinsic_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pallet_str, | |
extrinsic_str, |
let pallet = String::from_utf8(key_info.pallet_name.clone()) | ||
.expect("encoded from string"); | ||
let item = String::from_utf8(key_info.storage_name.clone()) | ||
.expect("encoded from string"); | ||
let comment = format!( | ||
"Proof: `{}::{}` (`max_values`: {:?}, `max_size`: {:?}, mode: `{:?}`)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Proof: `{}::{}` (`max_values`: {:?}, `max_size`: {:?}, mode: `{:?}`)", | |
"Proof: `{pallet_name}::{storage_name}` (`max_values`: {:?}, `max_size`: {:?}, mode: `{:?}`)", |
let comment = format!( | ||
"Proof: `{}::{}` (`max_values`: {:?}, `max_size`: {:?}, mode: `{:?}`)", | ||
pallet, item, key_info.max_values, key_info.max_size, | ||
pallet_name, storage_name, key_info.max_values, key_info.max_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pallet_name, storage_name, key_info.max_values, key_info.max_size, | |
key_info.max_values, key_info.max_size, |
let pallet_str = String::from_utf8(pallet.clone()).expect("Encoded from String; qed"); | ||
let extrinsic_str = String::from_utf8(extrinsic.clone()).expect("Encoded from String; qed"); | ||
let pov_modes_str = pov_modes.into_iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick. In general we don't use Hungarian notation or any variation of it. So in this case I'd rename these variables to just pallet_name
, extrinsic_name
and pov_modes
(as done some files below - writer.rs?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, sure thing. I've updated the variable names for pallet_str
, extrinsic_str
and removed pov_modes_str
as pov_modes
was already being passed in
Thanks for the review @bkchr, all of the comments have been addressed |
@@ -329,12 +333,10 @@ impl PalletCmd { | |||
let mut component_ranges = HashMap::<(Vec<u8>, Vec<u8>), Vec<ComponentRange>>::new(); | |||
let pov_modes = Self::parse_pov_modes(&benchmarks_to_run)?; | |||
|
|||
for (pallet, extrinsic, components, _) in benchmarks_to_run.clone() { | |||
for (pallet, extrinsic, components, _, pallet_str, extrinsic_str) in benchmarks_to_run.clone() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (pallet, extrinsic, components, _, pallet_str, extrinsic_str) in benchmarks_to_run.clone() { | |
for (pallet, extrinsic, components, _, pallet, extrinsic) in benchmarks_to_run.clone() { |
Types dont need to be in the var name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
.expect("Encoded from String; qed"), | ||
String::from_utf8(extrinsic.clone()) | ||
.expect("Encoded from String; qed"), | ||
"Running benchmark: {pallet_str}.{extrinsic_str}({} args) {}/{} {}/{}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Running benchmark: {pallet_str}.{extrinsic_str}({} args) {}/{} {}/{}", | |
"Running benchmark: {pallet_str}::{extrinsic_str}({} args) {}/{} {}/{}", |
Noticed recently that it should be consistent with the print above.
let pallet_string = String::from_utf8(batch.pallet.clone()).unwrap(); | ||
let instance_string = String::from_utf8(batch.instance.clone()).unwrap(); | ||
let pallet_name = String::from_utf8(batch.pallet.clone()).unwrap(); | ||
let instance_name = String::from_utf8(batch.instance.clone()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally i thought that already the types in BenchmarkBatchSplitResults
and BenchmarkBatch
should be converted, but it would mean to duplicate or generitize the types.
Guess this is a good start for now.
bot fmt |
@ggwpez https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5348374 was started for your command Comment |
@ggwpez Command |
81d447a
…head-data * origin/master: (51 commits) Runtime Upgrade ref docs and Single Block Migration example pallet (#1554) Collator overseer builder unification (#3335) Introduce storage attr macro `#[disable_try_decode_storage]` and set it on `System::Events` and `ParachainSystem::HostConfiguration` (#3454) Add Polkadotters bootnoders per IBP application (#3423) Add documentation around FRAME Origin (#3362) Bridge zombienet tests: Check amount received at destination (#3490) Snowbridge benchmark tests fix (#3424) fix(zombienet): increase timeout in download artifacts (#3376) Cleanup String::from_utf8 (#3446) [prdoc] Validate crate names (#3467) Limit max execution time for `test-linux-stable` CI jobs (#3483) Introduce Notification block pinning limit (#2935) frame-support: Improve error reporting when having too many pallets (#3478) add Encointer as trusted teleporter for Westend (#3411) [pallet-xcm] Adjust benchmarks (teleport_assets/reserve_transfer_assets) not relying on ED (#3464) Add more debug logs to understand if statement-distribution misbehaving (#3419) Remove redundant parachains assigner pallet. (#3457) Use generic hash for runtime wasm in resolve_state_version_from_wasm (#3447) Runtime: allow backing multiple candidates of same parachain on different cores (#3231) Bridge zombienet tests: move all "framework" files under one folder (#3462) ...
# Description *Refactors `String::from_utf8` usage in the pallet benchmarking Fixes paritytech#389 --------- Co-authored-by: command-bot <>
Description
*Refactors
String::from_utf8
usage in the pallet benchmarkingFixes #389