mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
Add PoV Tracking to Benchmarking Pipeline (#8559)
* Added a function to estimate proof size for benchmarking * integrate proof_size into benchmarking pipeline * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * fix tests * one more test * Update bench.rs * Update utils/frame/benchmarking-cli/src/writer.rs Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> * Update utils/frame/benchmarking-cli/src/command.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: arkpar <arkady.paronyan@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Alexander Popiak <alexander.popiak@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -38,6 +38,7 @@ pub enum BenchmarkSelector {
|
||||
StorageRootTime,
|
||||
Reads,
|
||||
Writes,
|
||||
ProofSize,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -86,6 +87,7 @@ impl Analysis {
|
||||
BenchmarkSelector::StorageRootTime => result.storage_root_time,
|
||||
BenchmarkSelector::Reads => result.reads.into(),
|
||||
BenchmarkSelector::Writes => result.writes.into(),
|
||||
BenchmarkSelector::ProofSize => result.proof_size.into(),
|
||||
}
|
||||
).collect();
|
||||
|
||||
@@ -126,6 +128,7 @@ impl Analysis {
|
||||
BenchmarkSelector::StorageRootTime => result.storage_root_time,
|
||||
BenchmarkSelector::Reads => result.reads.into(),
|
||||
BenchmarkSelector::Writes => result.writes.into(),
|
||||
BenchmarkSelector::ProofSize => result.proof_size.into(),
|
||||
};
|
||||
(result.components[i].1, data)
|
||||
})
|
||||
@@ -190,6 +193,7 @@ impl Analysis {
|
||||
BenchmarkSelector::StorageRootTime => result.storage_root_time,
|
||||
BenchmarkSelector::Reads => result.reads.into(),
|
||||
BenchmarkSelector::Writes => result.writes.into(),
|
||||
BenchmarkSelector::ProofSize => result.proof_size.into(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -370,6 +374,7 @@ mod tests {
|
||||
repeat_reads: 0,
|
||||
writes,
|
||||
repeat_writes: 0,
|
||||
proof_size: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -764,12 +764,21 @@ macro_rules! impl_benchmark {
|
||||
"Start Benchmark: {:?}", c
|
||||
);
|
||||
|
||||
let start_pov = $crate::benchmarking::proof_size();
|
||||
let start_extrinsic = $crate::benchmarking::current_time();
|
||||
|
||||
closure_to_benchmark()?;
|
||||
|
||||
let finish_extrinsic = $crate::benchmarking::current_time();
|
||||
let elapsed_extrinsic = finish_extrinsic - start_extrinsic;
|
||||
let end_pov = $crate::benchmarking::proof_size();
|
||||
|
||||
// Calculate the diff caused by the benchmark.
|
||||
let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic);
|
||||
let diff_pov = match (start_pov, end_pov) {
|
||||
(Some(start), Some(end)) => end.saturating_sub(start),
|
||||
_ => Default::default(),
|
||||
};
|
||||
|
||||
// Commit the changes to get proper write count
|
||||
$crate::benchmarking::commit_db();
|
||||
$crate::log::trace!(
|
||||
@@ -796,6 +805,7 @@ macro_rules! impl_benchmark {
|
||||
repeat_reads: read_write_count.1,
|
||||
writes: read_write_count.2,
|
||||
repeat_writes: read_write_count.3,
|
||||
proof_size: diff_pov,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ pub struct BenchmarkResults {
|
||||
pub repeat_reads: u32,
|
||||
pub writes: u32,
|
||||
pub repeat_writes: u32,
|
||||
pub proof_size: u32,
|
||||
}
|
||||
|
||||
/// Configuration used to setup and run runtime benchmarks.
|
||||
@@ -162,6 +163,11 @@ pub trait Benchmarking {
|
||||
whitelist.retain(|x| x.key != remove);
|
||||
self.set_whitelist(whitelist);
|
||||
}
|
||||
|
||||
/// Get current estimated proof size.
|
||||
fn proof_size(&self) -> Option<u32> {
|
||||
self.proof_size()
|
||||
}
|
||||
}
|
||||
|
||||
/// The pallet benchmarking trait.
|
||||
|
||||
Reference in New Issue
Block a user