Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 14 additions & 4 deletions src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl Controller {
let mut vms = Vec::with_capacity(self.instances.len());
for (id, instance) in &self.instances {
let status = instance.status.read().await;
let (read_io_count, write_io_count, other_io_count) = match status.perf {
let (read_io_count, write_io_count, other_io_count) = match &status.perf {
Some(perf) => {
(perf.read_io_count, perf.write_io_count, perf.other_io_count)
}
Expand Down Expand Up @@ -441,8 +441,18 @@ impl Controller {
other_iops: s.other_iops,
read_bw_bps: s.read_bytes_per_second,
write_bw_bps: s.write_bytes_per_second,
read_latency_us: None,
write_latency_us: None,
read_latency_us: s.read_latency_us.map(|latency| SnapshotLatency {
p50: latency.p50,
p95: latency.p95,
p99: latency.p99,
avg: latency.avg,
}),
write_latency_us: s.write_latency_us.map(|latency| SnapshotLatency {
p50: latency.p50,
p95: latency.p95,
p99: latency.p99,
avg: latency.avg,
}),
num_queues: None,
per_vq_depth: None,
qd_total: None,
Expand Down Expand Up @@ -547,7 +557,7 @@ impl Controller {

let status = instance.status.read().await;
let previous_count = status.thread_count;
let previous_io_count = match status.perf {
let previous_io_count = match &status.perf {
Some(perf) => perf.total_io_count(),
None => 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/engines/threshold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl ScalingEngine for ThresholdEngine {
(
status.per_thread_util,
status.thread_count,
match status.perf {
match &status.perf {
Some(perf) => perf.total_io_count(),
None => 0,
},
Expand Down
42 changes: 40 additions & 2 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ impl Instance {
Self::update_perf_rates(&mut status, &snapshot.perf, now);
status.thread_count = snapshot.thread_count;
status.vcpu_count = snapshot.vcpu_count;
status.perf = snapshot.perf;
status.perf = snapshot.perf.clone();
status.read_latency_us = snapshot.perf.as_ref().and_then(|perf| perf.read_latency_us);
status.write_latency_us = snapshot
.perf
.as_ref()
.and_then(|perf| perf.write_latency_us);
status.alive = true;
let backend_util = snapshot.per_thread_util.map(|util| util.clamp(0.0, 1.0));
if let Some(backend_util) = backend_util {
Expand Down Expand Up @@ -395,6 +400,10 @@ pub struct InstanceStatus {
pub write_iops: u64,
/// Latest other-operation rate per second.
pub other_iops: u64,
/// Latest read-latency histogram digest.
pub read_latency_us: Option<LatencySummary>,
/// Latest write-latency histogram digest.
pub write_latency_us: Option<LatencySummary>,
/// Latest read bandwidth in bytes per second.
pub read_bytes_per_second: u64,
/// Latest write bandwidth in bytes per second.
Expand Down Expand Up @@ -431,8 +440,21 @@ pub struct TaskCpuSample {
pub cpu_ticks: u64,
}

/// Backend-neutral latency histogram digest in microseconds.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Deserialize)]
pub struct LatencySummary {
/// Median latency.
pub p50: u64,
/// 95th-percentile latency.
pub p95: u64,
/// 99th-percentile latency.
pub p99: u64,
/// Histogram-derived arithmetic mean.
pub avg: u64,
}

/// Backend-neutral performance counters from one snapshot.
#[derive(Debug, Default, Clone, Copy)]
#[derive(Debug, Default, Clone)]
pub struct InstancePerfSample {
/// Cumulative completed reads.
pub read_io_count: u64,
Expand All @@ -444,6 +466,22 @@ pub struct InstancePerfSample {
pub read_bytes_total: u64,
/// Cumulative bytes written.
pub write_bytes_total: u64,
/// Cumulative sequential-read operations.
pub read_seq_ops: u64,
/// Cumulative random-read operations.
pub read_rand_ops: u64,
/// Cumulative sequential-write operations.
pub write_seq_ops: u64,
/// Cumulative random-write operations.
pub write_rand_ops: u64,
/// Cumulative operations smaller than the backend's small-I/O cutoff.
pub small_ops: u64,
/// Cumulative operations at least as large as the backend's cutoff.
pub large_ops: u64,
/// Read-latency digest, when the backend has read samples.
pub read_latency_us: Option<LatencySummary>,
/// Write-latency digest, when the backend has write samples.
pub write_latency_us: Option<LatencySummary>,
}

impl InstancePerfSample {
Expand Down
Loading