Skip to content

Commit e122ff1

Browse files
committed
feat(metrics/net): add tx backlog metrics
This metric accumulates the number of pending requests sitting in the Tx virtio queue while a request is being processed. This may give an insight at how sensible it would be to think of processing ingress traffic parallelly. (cherry picked from commit 3753f35) Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent ae803c0 commit e122ff1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ impl Net {
592592
let tx_queue = &mut self.queues[TX_INDEX];
593593

594594
while let Some(head) = tx_queue.pop_or_enable_notification(mem) {
595+
self.metrics
596+
.tx_remaining_reqs_count
597+
.add(tx_queue.len(mem).into());
595598
let head_index = head.index;
596599
// Parse IoVecBuffer from descriptor head
597600
let buffer = match IoVecBuffer::from_descriptor_chain(head) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ pub struct NetDeviceMetrics {
206206
pub tx_rate_limiter_throttled: SharedIncMetric,
207207
/// Number of packets with a spoofed mac, sent by the guest.
208208
pub tx_spoofed_mac_count: SharedIncMetric,
209+
/// Number of remaining requests in the TX queue.
210+
pub tx_remaining_reqs_count: SharedIncMetric,
209211
}
210212

211213
impl NetDeviceMetrics {
@@ -269,6 +271,8 @@ impl NetDeviceMetrics {
269271
.add(other.tx_rate_limiter_throttled.fetch_diff());
270272
self.tx_spoofed_mac_count
271273
.add(other.tx_spoofed_mac_count.fetch_diff());
274+
self.tx_remaining_reqs_count
275+
.add(other.tx_remaining_reqs_count.fetch_diff());
272276
}
273277
}
274278

tests/host_tools/fcmetrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def validate_fc_metrics(metrics):
138138
"tx_rate_limiter_event_count",
139139
"tx_rate_limiter_throttled",
140140
"tx_spoofed_mac_count",
141+
"tx_remaining_reqs_count",
141142
],
142143
"patch_api_requests": [
143144
"drive_count",

0 commit comments

Comments
 (0)