Skip to content

Commit 99a437e

Browse files
committed
test: run throughput perf tests with swiotlb enabled
On aarch64, additionally parametrize our throughput performance tests (network, block and vsock) by swiotlb size, to get a feeling for the performance impact bounce buffering will have. Try out different sizes of swiotlb region to see whether we can identify a cut off. Signed-off-by: Patrick Roy <[email protected]>
1 parent a6149ca commit 99a437e

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,16 @@ def io_engine(request):
376376
return request.param
377377

378378

379+
@pytest.fixture(
380+
params=[None, 16, 32, 64] if platform.machine() == "aarch64" else [None]
381+
)
382+
def memory_config(request):
383+
"""Differently configured swiotlb regions. Only supported on aarch64"""
384+
if request.param is None:
385+
return None
386+
return {"initial_swiotlb_size": request.param}
387+
388+
379389
@pytest.fixture
380390
def results_dir(request):
381391
"""

tests/framework/microvm.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def __init__(
248248
self.disks_vhost_user = {}
249249
self.vcpus_count = None
250250
self.mem_size_bytes = None
251+
self.memory_config = None
251252
self.cpu_template_name = None
252253
# The given custom CPU template will be set in basic_config() but could
253254
# be overwritten via set_cpu_template().
@@ -462,6 +463,7 @@ def dimensions(self):
462463
"rootfs": self.rootfs_file.name,
463464
"vcpus": str(self.vcpus_count),
464465
"guest_memory": f"{self.mem_size_bytes / (1024 * 1024)}MB",
466+
**(self.memory_config if self.memory_config else {}),
465467
}
466468

467469
@property
@@ -729,6 +731,7 @@ def basic_config(
729731
rootfs_io_engine=None,
730732
cpu_template: Optional[str] = None,
731733
enable_entropy_device=False,
734+
memory_config=None,
732735
):
733736
"""Shortcut for quickly configuring a microVM.
734737
@@ -747,15 +750,23 @@ def basic_config(
747750
748751
Reference: file:../../src/vmm/src/vmm_config/boot_source.rs::DEFAULT_KERNEL_CMDLINE
749752
"""
753+
# Have to do it this way as otherwise A/B-tests fail if the 'A' revision
754+
# of Firecracker doesn't knwo about the mem_config parameter.
755+
kwargs = {}
756+
if memory_config is not None:
757+
kwargs["mem_config"] = memory_config
758+
750759
self.api.machine_config.put(
751760
vcpu_count=vcpu_count,
752761
smt=smt,
753762
mem_size_mib=mem_size_mib,
754763
track_dirty_pages=track_dirty_pages,
755764
huge_pages=huge_pages,
765+
**kwargs,
756766
)
757767
self.vcpus_count = vcpu_count
758768
self.mem_size_bytes = mem_size_mib * 2**20
769+
self.memory_config = memory_config
759770

760771
if self.custom_cpu_template is not None:
761772
self.set_cpu_template(self.custom_cpu_template)

tests/integration_tests/performance/test_block_ab.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,20 @@ def test_block_performance(
148148
fio_mode,
149149
fio_block_size,
150150
io_engine,
151+
memory_config,
151152
metrics,
152153
):
153154
"""
154155
Execute block device emulation benchmarking scenarios.
155156
"""
157+
if memory_config is not None and "6.1" not in guest_kernel_acpi:
158+
pytest.skip("swiotlb only supported on aarch64/6.1")
159+
156160
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
157161
vm.spawn(log_level="Info", emit_metrics=True)
158-
vm.basic_config(vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB)
162+
vm.basic_config(
163+
vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB, memory_config=memory_config
164+
)
159165
vm.add_net_iface()
160166
# Add a secondary block device for benchmark tests.
161167
fs = drive_tools.FilesystemFile(

tests/integration_tests/performance/test_network_ab.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,21 @@ def consume_ping_output(ping_putput, request_per_round):
3636

3737

3838
@pytest.fixture
39-
def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs):
39+
def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs, memory_config):
4040
"""Creates a microvm with the networking setup used by the performance tests in this file.
4141
This fixture receives its vcpu count via indirect parameterization"""
4242

43+
if memory_config is not None and "6.1" not in guest_kernel_acpi:
44+
pytest.skip("swiotlb only supported on aarch64/6.1")
45+
4346
guest_mem_mib = 1024
4447
guest_vcpus = request.param
4548

4649
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
4750
vm.spawn(log_level="Info", emit_metrics=True)
48-
vm.basic_config(vcpu_count=guest_vcpus, mem_size_mib=guest_mem_mib)
51+
vm.basic_config(
52+
vcpu_count=guest_vcpus, mem_size_mib=guest_mem_mib, memory_config=memory_config
53+
)
4954
vm.add_net_iface()
5055
vm.start()
5156
vm.pin_threads(0)

tests/integration_tests/performance/test_vsock_ab.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ def guest_command(self, port_offset):
7373
@pytest.mark.parametrize("payload_length", ["64K", "1024K"], ids=["p64K", "p1024K"])
7474
@pytest.mark.parametrize("mode", ["g2h", "h2g", "bd"])
7575
def test_vsock_throughput(
76-
microvm_factory, guest_kernel_acpi, rootfs, vcpus, payload_length, mode, metrics
76+
microvm_factory,
77+
guest_kernel_acpi,
78+
rootfs,
79+
vcpus,
80+
payload_length,
81+
mode,
82+
metrics,
83+
memory_config,
7784
):
7885
"""
7986
Test vsock throughput for multiple vm configurations.
@@ -84,10 +91,15 @@ def test_vsock_throughput(
8491
if mode == "bd" and vcpus < 2:
8592
pytest.skip("bidrectional test only done with at least 2 vcpus")
8693

94+
if memory_config is not None and "6.1" not in guest_kernel_acpi:
95+
pytest.skip("swiotlb only supported on aarch64/6.1")
96+
8797
mem_size_mib = 1024
8898
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
8999
vm.spawn(log_level="Info", emit_metrics=True)
90-
vm.basic_config(vcpu_count=vcpus, mem_size_mib=mem_size_mib)
100+
vm.basic_config(
101+
vcpu_count=vcpus, mem_size_mib=mem_size_mib, memory_config=memory_config
102+
)
91103
vm.add_net_iface()
92104
# Create a vsock device
93105
vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path="/" + VSOCK_UDS_PATH)

0 commit comments

Comments
 (0)