mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 05:47:58 +00:00
Follow ups for benchmark machine (#11270)
* Follow ups for the MachineCmd Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix CI Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add to node-template Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix test with feature flag Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Lower disk requirements Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add ExecutionLimit to the disk benchmarks Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Add doc Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Review fixes Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename DISK_WRITE_LIMIT -> DEFAULT_DISK_EXECUTION_LIMIT Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rename POLKADOT_REFERENCE_HARDWARE -> SUBSTRATE_REFERENCE_HARDWARE Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix build profile + add license Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove deps Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Set tolerance to 10% Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Ignore test I cannot reproduce the CI error, even with the full command: cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path ./bin/node/cli/Cargo.toml I will put an 'ignore' on that test for now, since it works for me and is worth having. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove test Still cannot reproduce the error and it fails in the CI. Removing it now. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9a3201ef3d
commit
9980d314b1
@@ -241,10 +241,16 @@ fn random_data(size: usize) -> Vec<u8> {
|
||||
buffer
|
||||
}
|
||||
|
||||
pub fn benchmark_disk_sequential_writes(directory: &Path) -> Result<u64, String> {
|
||||
/// A default [`ExecutionLimit`] that can be used to call [`benchmark_disk_sequential_writes`]
|
||||
/// and [`benchmark_disk_random_writes`].
|
||||
pub const DEFAULT_DISK_EXECUTION_LIMIT: ExecutionLimit =
|
||||
ExecutionLimit::Both { max_iterations: 32, max_duration: Duration::from_millis(300) };
|
||||
|
||||
pub fn benchmark_disk_sequential_writes(
|
||||
limit: ExecutionLimit,
|
||||
directory: &Path,
|
||||
) -> Result<u64, String> {
|
||||
const SIZE: usize = 64 * 1024 * 1024;
|
||||
const MAX_ITERATIONS: usize = 32;
|
||||
const MAX_DURATION: Duration = Duration::from_millis(300);
|
||||
|
||||
let buffer = random_data(SIZE);
|
||||
let path = directory.join(".disk_bench_seq_wr.tmp");
|
||||
@@ -273,14 +279,21 @@ pub fn benchmark_disk_sequential_writes(directory: &Path) -> Result<u64, String>
|
||||
Ok(())
|
||||
};
|
||||
|
||||
benchmark("disk sequential write score", SIZE, MAX_ITERATIONS, MAX_DURATION, run)
|
||||
.map(|s| s as u64)
|
||||
benchmark(
|
||||
"disk sequential write score",
|
||||
SIZE,
|
||||
limit.max_iterations(),
|
||||
limit.max_duration(),
|
||||
run,
|
||||
)
|
||||
.map(|s| s as u64)
|
||||
}
|
||||
|
||||
pub fn benchmark_disk_random_writes(directory: &Path) -> Result<u64, String> {
|
||||
pub fn benchmark_disk_random_writes(
|
||||
limit: ExecutionLimit,
|
||||
directory: &Path,
|
||||
) -> Result<u64, String> {
|
||||
const SIZE: usize = 64 * 1024 * 1024;
|
||||
const MAX_ITERATIONS: usize = 32;
|
||||
const MAX_DURATION: Duration = Duration::from_millis(300);
|
||||
|
||||
let buffer = random_data(SIZE);
|
||||
let path = directory.join(".disk_bench_rand_wr.tmp");
|
||||
@@ -333,8 +346,14 @@ pub fn benchmark_disk_random_writes(directory: &Path) -> Result<u64, String> {
|
||||
};
|
||||
|
||||
// We only wrote half of the bytes hence `SIZE / 2`.
|
||||
benchmark("disk random write score", SIZE / 2, MAX_ITERATIONS, MAX_DURATION, run)
|
||||
.map(|s| s as u64)
|
||||
benchmark(
|
||||
"disk random write score",
|
||||
SIZE / 2,
|
||||
limit.max_iterations(),
|
||||
limit.max_duration(),
|
||||
run,
|
||||
)
|
||||
.map(|s| s as u64)
|
||||
}
|
||||
|
||||
/// Benchmarks the verification speed of sr25519 signatures.
|
||||
@@ -389,7 +408,8 @@ pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench {
|
||||
|
||||
if let Some(scratch_directory) = scratch_directory {
|
||||
hwbench.disk_sequential_write_score =
|
||||
match benchmark_disk_sequential_writes(scratch_directory) {
|
||||
match benchmark_disk_sequential_writes(DEFAULT_DISK_EXECUTION_LIMIT, scratch_directory)
|
||||
{
|
||||
Ok(score) => Some(score),
|
||||
Err(error) => {
|
||||
log::warn!("Failed to run the sequential write disk benchmark: {}", error);
|
||||
@@ -397,13 +417,14 @@ pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench {
|
||||
},
|
||||
};
|
||||
|
||||
hwbench.disk_random_write_score = match benchmark_disk_random_writes(scratch_directory) {
|
||||
Ok(score) => Some(score),
|
||||
Err(error) => {
|
||||
log::warn!("Failed to run the random write disk benchmark: {}", error);
|
||||
None
|
||||
},
|
||||
};
|
||||
hwbench.disk_random_write_score =
|
||||
match benchmark_disk_random_writes(DEFAULT_DISK_EXECUTION_LIMIT, scratch_directory) {
|
||||
Ok(score) => Some(score),
|
||||
Err(error) => {
|
||||
log::warn!("Failed to run the random write disk benchmark: {}", error);
|
||||
None
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
hwbench
|
||||
@@ -437,12 +458,17 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_benchmark_disk_sequential_writes() {
|
||||
assert!(benchmark_disk_sequential_writes("./".as_ref()).unwrap() > 0);
|
||||
assert!(
|
||||
benchmark_disk_sequential_writes(DEFAULT_DISK_EXECUTION_LIMIT, "./".as_ref()).unwrap() >
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_benchmark_disk_random_writes() {
|
||||
assert!(benchmark_disk_random_writes("./".as_ref()).unwrap() > 0);
|
||||
assert!(
|
||||
benchmark_disk_random_writes(DEFAULT_DISK_EXECUTION_LIMIT, "./".as_ref()).unwrap() > 0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user