Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c13b500
extract repeat out of benchmark
shawntabrizi Jul 19, 2021
c309539
remove r
shawntabrizi Jul 19, 2021
e909b9d
unused
shawntabrizi Jul 19, 2021
6e70861
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 19, 2021
30e9e5f
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 19, 2021
66c1dbb
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 19, 2021
cd01587
use linked map to keep order
shawntabrizi Jul 21, 2021
8c42f39
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 21, 2021
d0184a0
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 21, 2021
31810d9
Delete pallet_balances.rs
shawntabrizi Jul 21, 2021
1ab0066
Delete out
shawntabrizi Jul 21, 2021
257fbbb
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 21, 2021
ca5cdc5
steps and repeat to tuple (current_*, total_*)
shawntabrizi Jul 22, 2021
f42d16f
idea for list command
shawntabrizi Jul 22, 2021
8a0ed37
Merge branch 'master' into shawntabrizi-refactor-benchmarks
shawntabrizi Jul 29, 2021
81a7e77
fmt
shawntabrizi Jul 29, 2021
9467179
use benchmark list in cli
shawntabrizi Jul 30, 2021
e760e3e
handle steps in cli
shawntabrizi Jul 30, 2021
4d28ebe
Move client consensus parts out of primitives and into client/consens…
gilescope Jul 30, 2021
630ab7a
move log update to cli
shawntabrizi Jul 30, 2021
d4b3f9d
fmt
shawntabrizi Jul 30, 2021
39bd8c0
remove old todo
shawntabrizi Jul 30, 2021
fb8fc17
line width
shawntabrizi Jul 30, 2021
0f713c7
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 30, 2021
5627eba
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 30, 2021
ced0514
benchmark metadata function
shawntabrizi Jul 30, 2021
1945af5
don't need this warm up
shawntabrizi Jul 30, 2021
b243b02
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 30, 2021
14a4342
fix warnings
shawntabrizi Jul 30, 2021
ee3b2f7
fix node-template
shawntabrizi Jul 30, 2021
0ae6038
fix
shawntabrizi Jul 30, 2021
90c495c
Try merge shawntabrizi-refactor-benchmarks
emostov Jul 30, 2021
83289aa
save
emostov Jul 30, 2021
44875c5
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Jul 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle steps in cli
  • Loading branch information
shawntabrizi committed Jul 30, 2021
commit e760e3e9c2322f4f4902b3dec32a6ddebb6c2169
58 changes: 32 additions & 26 deletions frame/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,17 +846,20 @@ macro_rules! impl_benchmark {
Ok(())
};

let (current_step, total_steps) = steps;

if components.is_empty() {
if verify {
// If `--verify` is used, run the benchmark once to verify it would complete.
do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?;
// The CLI could ask to do more steps than is sensible, so we skip those.
if current_step == 0 {
if verify {
// If `--verify` is used, run the benchmark once to verify it would complete.
do_benchmark(Default::default(), &mut $crate::Vec::new(), true, 1, 1)?;
}
do_benchmark(Default::default(), &mut results, false, 1, 1)?;
}
do_benchmark(Default::default(), &mut results, false, 1, 1)?;
} else {
// Select the component we will be benchmarking. Each component will be benchmarked.
for (idx, (name, low, high)) in components.iter().enumerate() {
// Get the number of steps for this component.
let (_current_step, total_steps) = steps;

let lowest = lowest_range_values.get(idx).cloned().unwrap_or(*low);
let highest = highest_range_values.get(idx).cloned().unwrap_or(*high);
Expand All @@ -867,28 +870,31 @@ macro_rules! impl_benchmark {
let step_size = (diff / total_steps).max(1);
let num_of_steps = diff / step_size + 1;

for s in 0..num_of_steps {
// This is the value we will be testing for component `name`
let component_value = lowest + step_size * s;

// Select the max value for all the other components.
let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter()
.enumerate()
.map(|(idx, (n, _, h))|
if n == name {
(*n, component_value)
} else {
(*n, *highest_range_values.get(idx).unwrap_or(h))
}
)
.collect();
// The CLI could ask to do more steps than is sensible, so we just skip those.
if current_step >= num_of_steps {
continue;
}

if verify {
// If `--verify` is used, run the benchmark once to verify it would complete.
do_benchmark(&c, &mut $crate::Vec::new(), true, s, num_of_steps)?;
}
do_benchmark(&c, &mut results, false, s, num_of_steps)?;
// This is the value we will be testing for component `name`
let component_value = lowest + step_size * current_step;

// Select the max value for all the other components.
let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components.iter()
.enumerate()
.map(|(idx, (n, _, h))|
if n == name {
(*n, component_value)
} else {
(*n, *highest_range_values.get(idx).unwrap_or(h))
}
)
.collect();

if verify {
// If `--verify` is used, run the benchmark once to verify it would complete.
do_benchmark(&c, &mut $crate::Vec::new(), true, current_step, num_of_steps)?;
}
do_benchmark(&c, &mut results, false, current_step, num_of_steps)?;
}
}
return Ok(results);
Expand Down
68 changes: 36 additions & 32 deletions utils/frame/benchmarking-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,39 +173,43 @@ impl BenchmarkCmd {

// Run the benchmarks
for (pallet, extrinsic) in benchmarks_to_run {
for r in 0..self.repeat {
let result = StateMachine::<_, _, NumberFor<BB>, _>::new(
&state,
None,
&mut changes,
&executor,
"Benchmark_dispatch_benchmark",
&(
&pallet,
&extrinsic,
self.lowest_range_values.clone(),
self.highest_range_values.clone(),
(self.steps, self.steps),
(r, self.repeat),
!self.no_verify,
self.extra,
for s in 0..self.steps {
for r in 0..self.repeat {
// This should run only a single instance of a benchmark for `pallet` and
// `extrinsic`. All loops happen above.
let result = StateMachine::<_, _, NumberFor<BB>, _>::new(
&state,
None,
&mut changes,
&executor,
"Benchmark_dispatch_benchmark",
&(
&pallet,
&extrinsic,
self.lowest_range_values.clone(),
self.highest_range_values.clone(),
(s, self.steps),
(r, self.repeat),
!self.no_verify,
self.extra,
)
.encode(),
extensions(),
&sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?,
sp_core::testing::TaskExecutor::new(),
)
.encode(),
extensions(),
&sp_state_machine::backend::BackendRuntimeCode::new(&state).runtime_code()?,
sp_core::testing::TaskExecutor::new(),
)
.execute(strategy.into())
.map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?;

let (batch, last_storage_info) = <std::result::Result<
(Vec<BenchmarkBatch>, Vec<StorageInfo>),
String,
> as Decode>::decode(&mut &result[..])
.map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??;

batches.extend(batch);
storage_info = last_storage_info;
.execute(strategy.into())
.map_err(|e| format!("Error executing runtime benchmark: {:?}", e))?;

let (batch, last_storage_info) = <std::result::Result<
(Vec<BenchmarkBatch>, Vec<StorageInfo>),
String,
> as Decode>::decode(&mut &result[..])
.map_err(|e| format!("Failed to decode benchmark results: {:?}", e))??;

batches.extend(batch);
storage_info = last_storage_info;
}
}
}

Expand Down