Skip to content

Commit 4ff58ad

Browse files
committed
test(vhost-user): add perf test for vhost-user-blk
The test spins the qemu vhost-user-blk backend and runs the same tests as for the virtio block device. It also emits metrics as test_block_vhost_user_performance. Signed-off-by: Nikita Kalyazin <[email protected]>
1 parent cc0ec75 commit 4ff58ad

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

tests/integration_tests/performance/test_block_ab.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
import pytest
1111

1212
import host_tools.drive as drive_tools
13-
from framework.utils import CmdBuilder, get_cpu_percent, run_cmd
13+
from framework.utils import CmdBuilder, ProcessManager, get_cpu_percent, run_cmd
14+
from framework.utils_vhost_user_backend import (
15+
VHOST_USER_SOCKET,
16+
spawn_vhost_user_backend,
17+
)
1418

1519
# size of the block device used in the test, in MB
1620
BLOCK_DEVICE_SIZE_MB = 2048
@@ -188,3 +192,58 @@ def test_block_performance(
188192
**vm.dimensions,
189193
}
190194
)
195+
196+
def pin_backend(backend, cpu_id: int):
197+
"""Pin the vhost-user backend to a cpu list."""
198+
return ProcessManager.set_cpu_affinity(backend.pid, [cpu_id])
199+
200+
201+
@pytest.mark.nonci
202+
@pytest.mark.parametrize("vcpus", [1, 2], ids=["1vcpu", "2vcpu"])
203+
@pytest.mark.parametrize("fio_mode", ["randread", "randwrite"])
204+
@pytest.mark.parametrize("fio_block_size", [4096], ids=["bs4096"])
205+
def test_block_vhost_user_performance(
206+
microvm_factory,
207+
guest_kernel,
208+
rootfs,
209+
vcpus,
210+
fio_mode,
211+
fio_block_size,
212+
metrics,
213+
):
214+
"""
215+
Execute block device emulation benchmarking scenarios.
216+
"""
217+
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
218+
vm.spawn(log_level="Info")
219+
vm.basic_config(vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB)
220+
vm.add_net_iface()
221+
222+
# Add a secondary block device for benchmark tests.
223+
fs = drive_tools.FilesystemFile(None, BLOCK_DEVICE_SIZE_MB)
224+
backend = spawn_vhost_user_backend(vm, fs.path, readonly=False)
225+
vm.add_vhost_user_block("scratch", VHOST_USER_SOCKET)
226+
vm.start()
227+
228+
# Pin uVM threads to physical cores.
229+
assert vm.pin_vmm(0), "Failed to pin firecracker thread."
230+
assert vm.pin_api(1), "Failed to pin fc_api thread."
231+
pin_backend(backend, 2)
232+
for i in range(vm.vcpus_count):
233+
assert vm.pin_vcpu(i, i + 3), f"Failed to pin fc_vcpu {i} thread."
234+
235+
logs_dir, cpu_load = run_fio(vm, fio_mode, fio_block_size)
236+
237+
process_fio_logs(vm, fio_mode, logs_dir, metrics)
238+
239+
for cpu_util_data_point in list(cpu_load["firecracker"].values())[0]:
240+
metrics.put_metric("cpu_utilization_vmm", cpu_util_data_point, "Percent")
241+
242+
metrics.set_dimensions(
243+
{
244+
"performance_test": "test_block_vhost_user_performance",
245+
"fio_mode": fio_mode,
246+
"fio_block_size": str(fio_block_size),
247+
**vm.dimensions,
248+
}
249+
)

0 commit comments

Comments
 (0)