Skip to content

Commit 8826f20

Browse files
committed
feat(metrics/block): add queue backlog length metric
This metric accumulates the number of pending requests sitting in the virtio queue while a request is being processed. By looking at this number, one may make a decision on whether an async IO solution would be beneficial. (cherry picked from commit 58a87ed) Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent bb57d28 commit 8826f20

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/vmm/src/devices/virtio/block/virtio/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ impl VirtioBlock {
424424
let mut used_any = false;
425425

426426
while let Some(head) = queue.pop_or_enable_notification(mem) {
427+
self.metrics.remaining_reqs_count.add(queue.len(mem).into());
427428
let processing_result = match Request::parse(&head, mem, self.disk.nsectors) {
428429
Ok(request) => {
429430
if request.rate_limit(&mut self.rate_limiter) {

src/vmm/src/devices/virtio/block/virtio/metrics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ pub struct BlockDeviceMetrics {
187187
/// Number of virtio events throttled because of the IO engine.
188188
/// This happens when the io_uring submission queue is full.
189189
pub io_engine_throttled_events: SharedIncMetric,
190+
/// Number of remaining requests in the queue.
191+
pub remaining_reqs_count: SharedIncMetric,
190192
}
191193

192194
impl BlockDeviceMetrics {
@@ -231,6 +233,8 @@ impl BlockDeviceMetrics {
231233
.add(other.rate_limiter_throttled_events.fetch_diff());
232234
self.io_engine_throttled_events
233235
.add(other.io_engine_throttled_events.fetch_diff());
236+
self.remaining_reqs_count
237+
.add(other.remaining_reqs_count.fetch_diff());
234238
}
235239
}
236240

tests/host_tools/fcmetrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def validate_fc_metrics(metrics):
5959
"write_count",
6060
"rate_limiter_throttled_events",
6161
"io_engine_throttled_events",
62+
"remaining_reqs_count",
6263
],
6364
"deprecated_api": [
6465
"deprecated_http_api_calls",

0 commit comments

Comments
 (0)