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;
|
|
|
|
|
|
|
|
mod performance_tests;
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
use argh::FromArgs;
|
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::{
|
2023-01-10 11:32:17 +00:00
|
|
|
fmt,
|
2022-05-19 15:44:17 +00:00
|
|
|
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>,
|
2023-03-13 08:02:15 +00:00
|
|
|
test_timeout: Option<u32>,
|
2022-05-19 15:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for PerformanceTestOverrides {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
if let Some(test_iterations) = self.test_iterations {
|
2023-03-13 08:02:15 +00:00
|
|
|
write!(f, "test_iterations = {test_iterations}, ")?;
|
|
|
|
}
|
|
|
|
if let Some(test_timeout) = self.test_timeout {
|
|
|
|
write!(f, "test_timeout = {test_timeout}")?;
|
2022-05-19 15:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-13 08:02:15 +00:00
|
|
|
#[derive(Clone)]
|
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>,
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: Option<(bool, bool)>, // First bool is for RX(true)/TX(false), second bool is for bandwidth or PPS
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Option<(FioOps, bool)>, // Second parameter controls whether we want bandwidth or IOPS
|
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-12-14 11:41:15 +00:00
|
|
|
output = format!("{output}, num_queues = {o}");
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
if let Some(o) = self.queue_size {
|
2022-12-14 11:41:15 +00:00
|
|
|
output = format!("{output}, queue_size = {o}");
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
2023-01-04 17:20:15 +00:00
|
|
|
if let Some(o) = self.net_control {
|
|
|
|
let (rx, bw) = o;
|
|
|
|
output = format!("{output}, rx = {rx}, bandwidth = {bw}");
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
2023-01-03 22:31:01 +00:00
|
|
|
if let Some(o) = &self.fio_control {
|
|
|
|
let (ops, bw) = o;
|
|
|
|
output = format!("{output}, fio_ops = {ops}, bandwidth = {bw}");
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
|
2022-12-14 11:41:15 +00:00
|
|
|
write!(f, "{output}")
|
2022-02-01 05:24:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: None,
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: 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)
|
|
|
|
{
|
2023-03-13 08:02:15 +00:00
|
|
|
// update the timeout in control if passed explicitly and run testcase with it
|
|
|
|
if let Some(test_timeout) = overrides.test_timeout {
|
|
|
|
let mut control: PerformanceTestControl = self.control.clone();
|
|
|
|
control.test_timeout = test_timeout;
|
|
|
|
metrics.push((self.func_ptr)(&control));
|
|
|
|
} else {
|
|
|
|
metrics.push((self.func_ptr)(&self.control));
|
|
|
|
}
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|
|
|
|
|
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
|
2023-03-13 08:02:15 +00:00
|
|
|
pub fn calc_timeout(&self, test_iterations: &Option<u32>, test_timeout: &Option<u32>) -> u64 {
|
|
|
|
((test_timeout.unwrap_or(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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 17:20:15 +00:00
|
|
|
const TEST_LIST: [PerformanceTest; 29] = [
|
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),
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: Some((true, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: Some((false, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: Some((true, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-04 17:20:15 +00:00
|
|
|
net_control: Some((false, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::bps_to_gbps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
2023-01-04 17:20:15 +00:00
|
|
|
PerformanceTest {
|
|
|
|
name: "virtio_net_throughput_single_queue_rx_pps",
|
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(256),
|
|
|
|
net_control: Some((true, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "virtio_net_throughput_single_queue_tx_pps",
|
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(256),
|
|
|
|
net_control: Some((false, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "virtio_net_throughput_multi_queue_rx_pps",
|
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(4),
|
|
|
|
queue_size: Some(256),
|
|
|
|
net_control: Some((true, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "virtio_net_throughput_multi_queue_tx_pps",
|
|
|
|
func_ptr: performance_net_throughput,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(4),
|
|
|
|
queue_size: Some(256),
|
|
|
|
net_control: Some((false, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::Read, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::Write, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::RandomRead, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::RandomWrite, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::Read, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::Write, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::RandomRead, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..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),
|
2023-01-03 22:31:01 +00:00
|
|
|
fio_control: Some((FioOps::RandomWrite, true)),
|
2022-02-22 14:18:41 +00:00
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
2022-03-03 10:18:42 +00:00
|
|
|
unit_adjuster: adjuster::Bps_to_MiBps,
|
2022-02-22 14:18:41 +00:00
|
|
|
},
|
2023-01-03 22:31:01 +00:00
|
|
|
PerformanceTest {
|
|
|
|
name: "block_read_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(1),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::Read, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_write_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(1),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::Write, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_random_read_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(1),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::RandomRead, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_random_write_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(1),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::RandomWrite, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_multi_queue_read_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::Read, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_multi_queue_write_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::Write, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_multi_queue_random_read_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::RandomRead, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
|
|
|
PerformanceTest {
|
|
|
|
name: "block_multi_queue_random_write_IOPS",
|
|
|
|
func_ptr: performance_block_io,
|
|
|
|
control: PerformanceTestControl {
|
|
|
|
num_queues: Some(2),
|
|
|
|
queue_size: Some(128),
|
|
|
|
fio_control: Some((FioOps::RandomWrite, false)),
|
|
|
|
..PerformanceTestControl::default()
|
|
|
|
},
|
|
|
|
unit_adjuster: adjuster::identity,
|
|
|
|
},
|
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;
|
2023-03-13 08:02:15 +00:00
|
|
|
let test_timeout = overrides.test_timeout;
|
2022-05-19 15:44:17 +00:00
|
|
|
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
|
2023-03-13 08:02:15 +00:00
|
|
|
let test_timeout = test.calc_timeout(&test_iterations, &test_timeout);
|
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()
|
|
|
|
}
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
#[derive(FromArgs)]
|
|
|
|
/// Generate the performance metrics data for Cloud Hypervisor
|
|
|
|
struct Options {
|
|
|
|
#[argh(switch, long = "list-tests")]
|
|
|
|
/// print the list of available metrics tests
|
|
|
|
list_tests: bool,
|
|
|
|
|
|
|
|
#[argh(option, long = "test-filter")]
|
|
|
|
/// filter metrics tests to run based on provided keywords
|
|
|
|
keywords: Vec<String>,
|
|
|
|
|
|
|
|
#[argh(option, long = "report-file")]
|
|
|
|
/// report file. Stderr is used if not specified
|
|
|
|
report_file: Option<String>,
|
|
|
|
|
|
|
|
#[argh(option, long = "iterations")]
|
|
|
|
/// override number of test iterations
|
|
|
|
iterations: Option<u32>,
|
|
|
|
|
2023-03-13 08:02:15 +00:00
|
|
|
#[argh(option, long = "timeout")]
|
|
|
|
/// override test timeout, Ex. --timeout 5
|
|
|
|
timeout: Option<u32>,
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
#[argh(switch, short = 'V', long = "version")]
|
|
|
|
/// print version information
|
|
|
|
version: bool,
|
|
|
|
}
|
|
|
|
|
2022-01-11 05:27:58 +00:00
|
|
|
fn main() {
|
2023-01-10 11:32:17 +00:00
|
|
|
let opts: Options = argh::from_env();
|
|
|
|
|
|
|
|
if opts.version {
|
2023-01-13 16:58:23 +00:00
|
|
|
println!("{} {}", env!("CARGO_BIN_NAME"), env!("BUILT_VERSION"));
|
2023-01-10 11:32:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-02-11 05:54:42 +00:00
|
|
|
|
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();
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
if opts.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;
|
|
|
|
}
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
let test_filter = opts.keywords.iter().collect::<Vec<&String>>();
|
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 {
|
2023-01-10 11:32:17 +00:00
|
|
|
test_iterations: opts.iterations,
|
2023-03-13 08:02:15 +00:00
|
|
|
test_timeout: opts.timeout,
|
2022-05-19 15:44:17 +00:00
|
|
|
});
|
|
|
|
|
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) => {
|
2022-12-14 11:41:15 +00:00
|
|
|
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();
|
|
|
|
|
2023-01-10 11:32:17 +00:00
|
|
|
let mut report_file: Box<dyn std::io::Write + Send> = if let Some(ref file) = opts.report_file {
|
|
|
|
Box::new(
|
|
|
|
std::fs::File::create(std::path::Path::new(file))
|
|
|
|
.map_err(|e| {
|
|
|
|
eprintln!("Error opening report file: {file}: {e}");
|
|
|
|
std::process::exit(1);
|
|
|
|
})
|
|
|
|
.unwrap(),
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
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| {
|
2022-12-14 11:41:15 +00:00
|
|
|
eprintln!("Error writing report file: {e}");
|
2022-03-14 10:06:29 +00:00
|
|
|
std::process::exit(1);
|
|
|
|
})
|
2022-02-15 16:11:58 +00:00
|
|
|
.unwrap();
|
2022-01-11 05:27:58 +00:00
|
|
|
}
|