2022-02-25 10:32:07 +00:00
|
|
|
// Copyright © 2022 Intel Corporation
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
//
|
|
|
|
|
2022-01-11 05:27:58 +00:00
|
|
|
// Custom harness to run performance tests
|
|
|
|
extern crate test_infra;
|
2022-02-11 05:54:42 +00:00
|
|
|
#[macro_use(crate_authors)]
|
|
|
|
extern crate clap;
|
2022-01-11 05:27:58 +00:00
|
|
|
|
|
|
|
mod performance_tests;
|
|
|
|
|
2022-10-04 14:52:43 +00:00
|
|
|
use clap::{Arg, ArgAction, Command as ClapCommand};
|
2022-01-11 05:27:58 +00:00
|
|
|
use performance_tests::*;
|
2022-05-17 21:04:38 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-05-19 15:44:17 +00:00
|
|
|
use std::{
|
|
|
|
env, fmt,
|
|
|
|
process::Command,
|
|
|
|
sync::{mpsc::channel, Arc},
|
|
|
|
thread,
|
|
|
|
time::Duration,
|
|
|
|
};
|
2022-08-24 18:44:30 +00:00
|
|
|
use test_infra::FioOps;
|
2022-02-15 16:11:58 +00:00
|
|
|
use thiserror::Error;
|
2022-02-01 05:24:13 +00:00
|
|
|
|
2022-02-15 16:11:58 +00:00
|
|
|
#[derive(Error, Debug)]
|
2022-02-01 05:24:13 +00:00
|
|
|
enum Error {
|
2022-02-15 16:11:58 +00:00
|
|
|
#[error("Error: test timed-out")]
|
2022-02-01 05:24:13 +00:00
|
|
|
TestTimeout,
|
2022-02-15 16:11:58 +00:00
|
|
|
#[error("Error: test failed")]
|
2022-02-01 05:24:13 +00:00
|
|
|
TestFailed,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
|
|
pub struct PerformanceTestResult {
|
|
|
|
name: String,
|
|
|
|
mean: f64,
|
|
|
|
std_dev: f64,
|
2022-02-10 23:32:58 +00:00
|
|
|
max: f64,
|
|
|
|
min: f64,
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
2022-01-11 05:27:58 +00:00
|
|
|
|
2022-02-11 02:02:03 +00:00
|
|
|
#[derive(Deserialize, Serialize)]
|
|
|
|
pub struct MetricsReport {
|
|
|
|
pub git_human_readable: String,
|
|
|
|
pub git_revision: String,
|
2022-02-25 17:35:19 +00:00
|
|
|
pub git_commit_date: String,
|
2022-02-11 02:02:03 +00:00
|
|
|
pub date: String,
|
|
|
|
pub results: Vec<PerformanceTestResult>,
|
|
|
|
}
|
|
|
|
|
2022-02-16 23:06:45 +00:00
|
|
|
impl Default for MetricsReport {
|
|
|
|
fn default() -> Self {
|
|
|
|
let mut git_human_readable = "".to_string();
|
2022-09-20 08:46:19 +00:00
|
|
|
if let Ok(git_out) = Command::new("git").args(["describe", "--dirty"]).output() {
|
2022-02-16 23:06:45 +00:00
|
|
|
if git_out.status.success() {
|
2022-06-10 14:39:04 +00:00
|
|
|
git_human_readable = String::from_utf8(git_out.stdout)
|
|
|
|
.unwrap()
|
|
|
|
.trim()
|
|
|
|
.to_string();
|
|
|
|
} else {
|
|
|
|
eprintln!(
|
|
|
|
"Error generating human readable git reference: {}",
|
|
|
|
String::from_utf8(git_out.stderr).unwrap()
|
|
|
|
);
|
2022-02-16 23:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut git_revision = "".to_string();
|
2022-09-20 08:46:19 +00:00
|
|
|
if let Ok(git_out) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
2022-02-16 23:06:45 +00:00
|
|
|
if git_out.status.success() {
|
2022-06-10 14:39:04 +00:00
|
|
|
git_revision = String::from_utf8(git_out.stdout)
|
|
|
|
.unwrap()
|
|
|
|
.trim()
|
|
|
|
.to_string();
|
|
|
|
} else {
|
|
|
|
eprintln!(
|
|
|
|
"Error generating git reference: {}",
|
|
|
|
String::from_utf8(git_out.stderr).unwrap()
|
|
|
|
);
|
2022-02-16 23:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 17:35:19 +00:00
|
|
|
let mut git_commit_date = "".to_string();
|
2022-02-16 23:06:45 +00:00
|
|
|
if let Ok(git_out) = Command::new("git")
|
2022-09-20 08:46:19 +00:00
|
|
|
.args(["show", "-s", "--format=%cd"])
|
2022-02-16 23:06:45 +00:00
|
|
|
.output()
|
|
|
|
{
|
|
|
|
if git_out.status.success() {
|
2022-06-10 14:39:04 +00:00
|
|
|
git_commit_date = String::from_utf8(git_out.stdout)
|
|
|
|
.unwrap()
|
|
|
|
.trim()
|
|
|
|
.to_string();
|
|
|
|
} else {
|
|
|
|
eprintln!(
|
|
|
|
"Error generating git commit date: {}",
|
|
|
|
String::from_utf8(git_out.stderr).unwrap()
|
|
|
|
);
|
2022-02-16 23:06:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetricsReport {
|
|
|
|
git_human_readable,
|
|
|
|
git_revision,
|
2022-02-25 17:35:19 +00:00
|
|
|
git_commit_date,
|
2022-02-16 23:06:45 +00:00
|
|
|
date: date(),
|
|
|
|
results: Vec::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-19 15:44:17 +00:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct PerformanceTestOverrides {
|
|
|
|
test_iterations: Option<u32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for PerformanceTestOverrides {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
if let Some(test_iterations) = self.test_iterations {
|
|
|
|
write!(f, "test_iterations = {}", test_iterations)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-11 05:27:58 +00:00
|
|
|
pub struct PerformanceTestControl {
|
2022-02-25 10:29:02 +00:00
|
|
|
test_timeout: u32,
|
2022-01-11 05:27:58 +00:00
|
|
|
test_iterations: u32,
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Option<u32>,
|
2022-01-11 05:27:58 +00:00
|
|
|
queue_size: Option<u32>,
|
|
|
|
net_rx: Option<bool>,
|
|
|
|
fio_ops: Option<FioOps>,
|
2022-05-05 14:38:18 +00:00
|
|
|
num_boot_vcpus: Option<u8>,
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
|
|
|
|
2022-02-01 05:24:13 +00:00
|
|
|
impl fmt::Display for PerformanceTestControl {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
let mut output = format!(
|
2022-02-25 11:08:16 +00:00
|
|
|
"test_timeout = {}s, test_iterations = {}",
|
2022-02-25 10:29:02 +00:00
|
|
|
self.test_timeout, self.test_iterations
|
2022-02-01 05:24:13 +00:00
|
|
|
);
|
2022-02-25 10:30:05 +00:00
|
|
|
if let Some(o) = self.num_queues {
|
2022-02-25 16:49:03 +00:00
|
|
|
output = format!("{}, num_queues = {}", output, o);
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
if let Some(o) = self.queue_size {
|
|
|
|
output = format!("{}, queue_size = {}", output, o);
|
|
|
|
}
|
|
|
|
if let Some(o) = self.net_rx {
|
|
|
|
output = format!("{}, net_rx = {}", output, o);
|
|
|
|
}
|
|
|
|
if let Some(o) = &self.fio_ops {
|
|
|
|
output = format!("{}, fio_ops = {}", output, o);
|
|
|
|
}
|
|
|
|
|
|
|
|
write!(f, "{}", output)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-22 14:18:41 +00:00
|
|
|
impl PerformanceTestControl {
|
|
|
|
const fn default() -> Self {
|
2022-01-11 05:27:58 +00:00
|
|
|
Self {
|
2022-02-25 10:29:02 +00:00
|
|
|
test_timeout: 10,
|
2022-02-25 10:27:14 +00:00
|
|
|
test_iterations: 5,
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: None,
|
2022-02-22 14:18:41 +00:00
|
|
|
queue_size: None,
|
|
|
|
net_rx: None,
|
|
|
|
fio_ops: None,
|
2022-05-05 14:38:18 +00:00
|
|
|
num_boot_vcpus: Some(1),
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// A performance test should finish within the a certain time-out and
|
|
|
|
/// return a performance metrics number (including the average number and
|
|
|
|
/// standard deviation)
|
|
|
|
struct PerformanceTest {
|
|
|
|
pub name: &'static str,
|
|
|
|
pub func_ptr: fn(&PerformanceTestControl) -> f64,
|
|
|
|
pub control: PerformanceTestControl,
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: fn(f64) -> f64,
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl PerformanceTest {
|
2022-05-19 15:44:17 +00:00
|
|
|
pub fn run(&self, overrides: &PerformanceTestOverrides) -> PerformanceTestResult {
|
2022-01-11 05:27:58 +00:00
|
|
|
let mut metrics = Vec::new();
|
2022-05-19 15:44:17 +00:00
|
|
|
for _ in 0..overrides
|
|
|
|
.test_iterations
|
|
|
|
.unwrap_or(self.control.test_iterations)
|
|
|
|
{
|
2022-01-11 05:27:58 +00:00
|
|
|
metrics.push((self.func_ptr)(&self.control));
|
|
|
|
}
|
|
|
|
|
2022-03-03 10:18:42 +00:00
|
|
|
let mean = (self.unit_adjuster)(mean(&metrics).unwrap());
|
|
|
|
let std_dev = (self.unit_adjuster)(std_deviation(&metrics).unwrap());
|
|
|
|
let max = (self.unit_adjuster)(metrics.clone().into_iter().reduce(f64::max).unwrap());
|
|
|
|
let min = (self.unit_adjuster)(metrics.clone().into_iter().reduce(f64::min).unwrap());
|
2022-01-11 05:27:58 +00:00
|
|
|
|
2022-02-01 05:24:13 +00:00
|
|
|
PerformanceTestResult {
|
|
|
|
name: self.name.to_string(),
|
|
|
|
mean,
|
|
|
|
std_dev,
|
2022-02-10 23:32:58 +00:00
|
|
|
max,
|
|
|
|
min,
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-11 05:27:58 +00:00
|
|
|
|
2022-02-01 05:24:13 +00:00
|
|
|
// Calculate the timeout for each test
|
|
|
|
// Note: To cover the setup/cleanup time, 20s is added for each iteration of the test
|
2022-05-19 15:44:17 +00:00
|
|
|
pub fn calc_timeout(&self, test_iterations: &Option<u32>) -> u64 {
|
|
|
|
((self.control.test_timeout + 20) * test_iterations.unwrap_or(self.control.test_iterations))
|
|
|
|
as u64
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mean(data: &[f64]) -> Option<f64> {
|
|
|
|
let count = data.len();
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
Some(data.iter().sum::<f64>() / count as f64)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn std_deviation(data: &[f64]) -> Option<f64> {
|
|
|
|
let count = data.len();
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
let mean = mean(data).unwrap();
|
|
|
|
let variance = data
|
|
|
|
.iter()
|
|
|
|
.map(|value| {
|
|
|
|
let diff = mean - *value;
|
|
|
|
diff * diff
|
|
|
|
})
|
|
|
|
.sum::<f64>()
|
|
|
|
/ count as f64;
|
|
|
|
|
|
|
|
Some(variance.sqrt())
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 10:18:42 +00:00
|
|
|
mod adjuster {
|
|
|
|
pub fn identity(v: f64) -> f64 {
|
|
|
|
v
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn s_to_ms(v: f64) -> f64 {
|
|
|
|
v * 1000.0
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn bps_to_gbps(v: f64) -> f64 {
|
|
|
|
v / (1_000_000_000_f64)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(non_snake_case)]
|
|
|
|
pub fn Bps_to_MiBps(v: f64) -> f64 {
|
|
|
|
v / (1 << 20) as f64
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-05 14:38:18 +00:00
|
|
|
const TEST_LIST: [PerformanceTest; 17] = [
|
2022-02-22 14:18:41 +00:00
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "boot_time_ms",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_boot_time,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:29:02 +00:00
|
|
|
test_timeout: 2,
|
2022-02-22 14:18:41 +00:00
|
|
|
test_iterations: 10,
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::s_to_ms,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "boot_time_pmem_ms",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_boot_time_pmem,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:29:02 +00:00
|
|
|
test_timeout: 2,
|
2022-02-22 14:18:41 +00:00
|
|
|
test_iterations: 10,
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::s_to_ms,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
2022-05-05 14:38:18 +00:00
|
|
|
PerformanceTest {
|
|
|
|
name: "boot_time_16_vcpus_ms",
|
|
|
|
func_ptr: performance_boot_time,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
test_timeout: 2,
|
|
|
|
test_iterations: 10,
|
|
|
|
num_boot_vcpus: Some(16),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::s_to_ms,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "boot_time_16_vcpus_pmem_ms",
|
|
|
|
func_ptr: performance_boot_time_pmem,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
test_timeout: 2,
|
|
|
|
test_iterations: 10,
|
|
|
|
num_boot_vcpus: Some(16),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::s_to_ms,
|
|
|
|
},
|
2022-02-22 14:18:41 +00:00
|
|
|
PerformanceTest {
|
2022-03-01 16:13:11 +00:00
|
|
|
name: "virtio_net_latency_us",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_net_latency,
|
2022-02-25 10:49:45 +00:00
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(256),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::identity,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "virtio_net_throughput_single_queue_rx_gbps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:46:10 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-22 14:18:41 +00:00
|
|
|
queue_size: Some(256),
|
|
|
|
net_rx: Some(true),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::bps_to_gbps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "virtio_net_throughput_single_queue_tx_gbps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:46:10 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-22 14:18:41 +00:00
|
|
|
queue_size: Some(256),
|
|
|
|
net_rx: Some(false),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::bps_to_gbps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "virtio_net_throughput_multi_queue_rx_gbps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:46:10 +00:00
|
|
|
num_queues: Some(4),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(256),
|
2022-02-22 14:18:41 +00:00
|
|
|
net_rx: Some(true),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::bps_to_gbps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "virtio_net_throughput_multi_queue_tx_gbps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:46:10 +00:00
|
|
|
num_queues: Some(4),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(256),
|
2022-02-22 14:18:41 +00:00
|
|
|
net_rx: Some(false),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::bps_to_gbps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_read_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(1),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::Read),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_write_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(1),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::Write),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_random_read_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(1),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::RandomRead),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_random_write_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(1),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::RandomWrite),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_multi_queue_read_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::Read),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_multi_queue_write_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::Write),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_multi_queue_random_read_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::RandomRead),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
PerformanceTest {
|
2022-03-03 10:18:42 +00:00
|
|
|
name: "block_multi_queue_random_write_MiBps",
|
2022-02-22 14:18:41 +00:00
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
2022-02-25 10:30:05 +00:00
|
|
|
num_queues: Some(2),
|
2022-02-25 11:00:39 +00:00
|
|
|
queue_size: Some(128),
|
2022-02-22 14:18:41 +00:00
|
|
|
fio_ops: Some(FioOps::RandomWrite),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
|
|
|
];
|
2022-01-11 05:27:58 +00:00
|
|
|
|
2022-05-19 15:44:17 +00:00
|
|
|
fn run_test_with_timeout(
|
|
|
|
test: &'static PerformanceTest,
|
|
|
|
overrides: &Arc<PerformanceTestOverrides>,
|
|
|
|
) -> Result<PerformanceTestResult, Error> {
|
2022-02-11 02:02:03 +00:00
|
|
|
let (sender, receiver) = channel::<Result<PerformanceTestResult, Error>>();
|
2022-05-19 15:44:17 +00:00
|
|
|
let test_iterations = overrides.test_iterations;
|
|
|
|
let overrides = overrides.clone();
|
2022-02-01 05:24:13 +00:00
|
|
|
thread::spawn(move || {
|
2022-05-19 15:44:17 +00:00
|
|
|
println!(
|
|
|
|
"Test '{}' running .. (control: {}, overrides: {})",
|
|
|
|
test.name, test.control, overrides
|
|
|
|
);
|
2022-02-01 05:24:13 +00:00
|
|
|
|
2022-05-19 15:44:17 +00:00
|
|
|
let output = match std::panic::catch_unwind(|| test.run(&overrides)) {
|
2022-02-01 05:24:13 +00:00
|
|
|
Ok(test_result) => {
|
|
|
|
println!(
|
|
|
|
"Test '{}' .. ok: mean = {}, std_dev = {}",
|
|
|
|
test_result.name, test_result.mean, test_result.std_dev
|
|
|
|
);
|
2022-02-11 02:02:03 +00:00
|
|
|
Ok(test_result)
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
Err(_) => Err(Error::TestFailed),
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = sender.send(output);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Todo: Need to cleanup/kill all hanging child processes
|
2022-05-19 15:44:17 +00:00
|
|
|
let test_timeout = test.calc_timeout(&test_iterations);
|
2022-02-01 05:24:13 +00:00
|
|
|
receiver
|
|
|
|
.recv_timeout(Duration::from_secs(test_timeout))
|
|
|
|
.map_err(|_| {
|
|
|
|
eprintln!(
|
|
|
|
"[Error] Test '{}' time-out after {} seconds",
|
|
|
|
test.name, test_timeout
|
|
|
|
);
|
|
|
|
Error::TestTimeout
|
|
|
|
})?
|
|
|
|
}
|
|
|
|
|
2022-02-11 02:02:03 +00:00
|
|
|
fn date() -> String {
|
|
|
|
let output = test_infra::exec_host_command_output("date");
|
|
|
|
String::from_utf8_lossy(&output.stdout).trim().to_string()
|
|
|
|
}
|
|
|
|
|
2022-01-11 05:27:58 +00:00
|
|
|
fn main() {
|
2022-02-11 05:54:42 +00:00
|
|
|
let cmd_arguments = ClapCommand::new("performance-metrics")
|
|
|
|
.version(env!("GIT_HUMAN_READABLE"))
|
|
|
|
.author(crate_authors!())
|
|
|
|
.about("Generate the performance metrics data for Cloud Hypervisor")
|
|
|
|
.arg(
|
|
|
|
Arg::new("test-filter")
|
|
|
|
.long("test-filter")
|
|
|
|
.help("Filter metrics tests to run based on provided keywords")
|
2022-10-04 14:52:43 +00:00
|
|
|
.num_args(1)
|
2022-02-11 05:54:42 +00:00
|
|
|
.required(false),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::new("list-tests")
|
|
|
|
.long("list-tests")
|
|
|
|
.help("Print the list of availale metrics tests")
|
2022-10-04 14:52:43 +00:00
|
|
|
.num_args(0)
|
|
|
|
.action(ArgAction::SetTrue)
|
2022-02-11 05:54:42 +00:00
|
|
|
.required(false),
|
|
|
|
)
|
2022-02-15 16:11:58 +00:00
|
|
|
.arg(
|
|
|
|
Arg::new("report-file")
|
|
|
|
.long("report-file")
|
|
|
|
.help("Report file. Standard error is used if not specified")
|
2022-10-04 14:52:43 +00:00
|
|
|
.num_args(1),
|
2022-02-15 16:11:58 +00:00
|
|
|
)
|
2022-05-19 15:44:17 +00:00
|
|
|
.arg(
|
|
|
|
Arg::new("iterations")
|
|
|
|
.long("iterations")
|
|
|
|
.help("Override number of test iterations")
|
2022-10-04 14:52:43 +00:00
|
|
|
.num_args(1),
|
2022-05-19 15:44:17 +00:00
|
|
|
)
|
2022-02-11 05:54:42 +00:00
|
|
|
.get_matches();
|
|
|
|
|
2022-03-18 09:47:30 +00:00
|
|
|
// It seems that the tool (ethr) used for testing the virtio-net latency
|
|
|
|
// is not stable on AArch64, and therefore the latency test is currently
|
|
|
|
// skipped on AArch64.
|
|
|
|
let test_list: Vec<&PerformanceTest> = TEST_LIST
|
|
|
|
.iter()
|
|
|
|
.filter(|t| !(cfg!(target_arch = "aarch64") && t.name == "virtio_net_latency_us"))
|
|
|
|
.collect();
|
|
|
|
|
2022-10-04 14:52:43 +00:00
|
|
|
if cmd_arguments.get_flag("list-tests") {
|
2022-03-18 09:47:30 +00:00
|
|
|
for test in test_list.iter() {
|
2022-02-11 05:54:42 +00:00
|
|
|
println!("\"{}\" ({})", test.name, test.control);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-04 14:52:43 +00:00
|
|
|
let test_filter = match cmd_arguments.get_many::<String>("test-filter") {
|
2022-02-11 05:54:42 +00:00
|
|
|
Some(s) => s.collect(),
|
|
|
|
None => Vec::new(),
|
|
|
|
};
|
2022-02-01 05:24:13 +00:00
|
|
|
|
2022-02-11 02:02:03 +00:00
|
|
|
// Run performance tests sequentially and report results (in both readable/json format)
|
2022-02-16 23:06:45 +00:00
|
|
|
let mut metrics_report: MetricsReport = Default::default();
|
2022-02-11 02:02:03 +00:00
|
|
|
|
2022-02-08 00:39:15 +00:00
|
|
|
init_tests();
|
|
|
|
|
2022-05-19 15:44:17 +00:00
|
|
|
let overrides = Arc::new(PerformanceTestOverrides {
|
|
|
|
test_iterations: cmd_arguments
|
2022-10-04 14:52:43 +00:00
|
|
|
.get_one::<String>("iterations")
|
2022-05-19 15:44:17 +00:00
|
|
|
.map(|s| s.parse())
|
|
|
|
.transpose()
|
|
|
|
.unwrap_or_default(),
|
|
|
|
});
|
|
|
|
|
2022-03-18 09:47:30 +00:00
|
|
|
for test in test_list.iter() {
|
2022-02-11 05:54:42 +00:00
|
|
|
if test_filter.is_empty() || test_filter.iter().any(|&s| test.name.contains(s)) {
|
2022-05-19 15:44:17 +00:00
|
|
|
match run_test_with_timeout(test, &overrides) {
|
2022-02-01 05:24:13 +00:00
|
|
|
Ok(r) => {
|
2022-02-11 02:02:03 +00:00
|
|
|
metrics_report.results.push(r);
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
eprintln!("Aborting test due to error: '{:?}'", e);
|
2022-03-14 09:51:11 +00:00
|
|
|
std::process::exit(1);
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
2022-02-01 05:24:13 +00:00
|
|
|
|
2022-02-08 00:39:15 +00:00
|
|
|
cleanup_tests();
|
|
|
|
|
2022-03-14 09:55:46 +00:00
|
|
|
let mut report_file: Box<dyn std::io::Write + Send> =
|
2022-10-04 14:52:43 +00:00
|
|
|
if let Some(file) = cmd_arguments.get_one::<String>("report-file") {
|
2022-03-14 09:55:46 +00:00
|
|
|
Box::new(
|
|
|
|
std::fs::File::create(std::path::Path::new(file))
|
2022-03-14 10:06:29 +00:00
|
|
|
.map_err(|e| {
|
|
|
|
eprintln!("Error opening report file: {}: {}", file, e);
|
|
|
|
std::process::exit(1);
|
|
|
|
})
|
2022-03-14 09:55:46 +00:00
|
|
|
.unwrap(),
|
|
|
|
)
|
|
|
|
} else {
|
2022-03-14 09:58:40 +00:00
|
|
|
Box::new(std::io::stdout())
|
2022-03-14 09:55:46 +00:00
|
|
|
};
|
|
|
|
|
2022-02-15 16:11:58 +00:00
|
|
|
report_file
|
2022-03-14 09:57:39 +00:00
|
|
|
.write_all(
|
2022-02-15 16:11:58 +00:00
|
|
|
serde_json::to_string_pretty(&metrics_report)
|
|
|
|
.unwrap()
|
|
|
|
.as_bytes(),
|
|
|
|
)
|
2022-03-14 10:06:29 +00:00
|
|
|
.map_err(|e| {
|
|
|
|
eprintln!("Error writing report file: {}", e);
|
|
|
|
std::process::exit(1);
|
|
|
|
})
|
2022-02-15 16:11:58 +00:00
|
|
|
.unwrap();
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|