From c0a81bc903021784d2d117470c6091e52dc8382e Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 11 Mar 2026 20:54:11 +0100 Subject: [PATCH] performance-metrics: Settle host before each test Flush host writeback queues, drop the page cache and sleep 1s for kernel housekeeping before each test run. The cloud-hypervisor block backend does buffered I/O on the host side, so dirty pages from prior write tests can accumulate and compete for I/O bandwidth with subsequent tests. Dropping caches ensures cold read tests get a consistent baseline rather than benefiting from data cached by prior tests. The brief cooldown lets the kernel finish tearing down KVM state and freeing pages from the previous VM before the next one starts. Requires root, which the metrics container provides. Silently fails otherwise. Signed-off-by: Anatol Belski --- performance-metrics/src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index 34986395a..bef0b74ab 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -1234,6 +1234,14 @@ fn cleanup_stale_processes() { thread::sleep(Duration::from_secs(2)); } +fn settle_host() { + let _ = Command::new("sync").status(); + let _ = Command::new("bash") + .args(["-c", "echo 3 > /proc/sys/vm/drop_caches"]) + .status(); + thread::sleep(Duration::from_secs(1)); +} + fn date() -> String { let output = test_infra::exec_host_command_output("date"); String::from_utf8_lossy(&output.stdout).trim().to_string() @@ -1334,6 +1342,7 @@ fn main() { for test in test_list.iter() { if test_filter.is_empty() || test_filter.iter().any(|&s| test.name.contains(s)) { + settle_host(); match run_test_with_timeout(test, &overrides) { Ok(r) => { metrics_report.results.push(r);