Skip to content

Commit db6d29b

Browse files
committed
fix: do not try to use put_dimensions to merge dimension sets
That's apparently not how that function works. Instead, it just associates a completely separate dimension set with the metric-to-be-emitted, and then emits it twice (with different dimensions sets). Needless to say, that's not what we want, so go back to centrally configuring all metrics with a single call to set_dimensions. Fixes: 31ee851 Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent ee47730 commit db6d29b

File tree

1 file changed

+44
-30
lines changed

1 file changed

+44
-30
lines changed

tests/integration_tests/performance/test_snapshot_ab.py

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def id(self):
4444
"""Computes a unique id for this test instance"""
4545
return "all_dev" if self.all_devices else f"{self.vcpus}vcpu_{self.mem}mb"
4646

47-
def boot_vm(self, microvm_factory, guest_kernel, rootfs, metrics) -> Microvm:
47+
def boot_vm(self, microvm_factory, guest_kernel, rootfs) -> Microvm:
4848
"""Creates the initial snapshot that will be loaded repeatedly to sample latencies"""
4949
vm = microvm_factory.build(
5050
guest_kernel,
@@ -74,16 +74,6 @@ def boot_vm(self, microvm_factory, guest_kernel, rootfs, metrics) -> Microvm:
7474
)
7575
vm.api.vsock.put(vsock_id="vsock0", guest_cid=3, uds_path="/v.sock")
7676

77-
metrics.set_dimensions(
78-
{
79-
"net_devices": str(self.nets),
80-
"block_devices": str(self.blocks),
81-
"vsock_devices": str(int(self.all_devices)),
82-
"balloon_devices": str(int(self.all_devices)),
83-
"huge_pages_config": str(self.huge_pages),
84-
**vm.dimensions,
85-
}
86-
)
8777
vm.start()
8878

8979
return vm
@@ -115,15 +105,23 @@ def test_restore_latency(
115105
116106
We only test a single guest kernel, as the guest kernel does not "participate" in snapshot restore.
117107
"""
118-
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs, metrics)
119-
120-
snapshot = vm.snapshot_full()
121-
vm.kill()
108+
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs)
122109

123-
metrics.put_dimensions(
124-
{"performance_test": "test_restore_latency", "uffd_handler": "None"}
110+
metrics.set_dimensions(
111+
{
112+
"net_devices": str(test_setup.nets),
113+
"block_devices": str(test_setup.blocks),
114+
"vsock_devices": str(int(test_setup.all_devices)),
115+
"balloon_devices": str(int(test_setup.all_devices)),
116+
"huge_pages_config": str(test_setup.huge_pages),
117+
"performance_test": "test_restore_latency",
118+
"uffd_handler": "None",
119+
**vm.dimensions,
120+
}
125121
)
126122

123+
snapshot = vm.snapshot_full()
124+
vm.kill()
127125
for microvm in microvm_factory.build_n_from_snapshot(snapshot, ITERATIONS):
128126
value = 0
129127
# Parse all metric data points in search of load_snapshot time.
@@ -151,7 +149,20 @@ def test_post_restore_latency(
151149
pytest.skip("huge page snapshots can only be restored using uffd")
152150

153151
test_setup = SnapshotRestoreTest(mem=1024, vcpus=2, huge_pages=huge_pages)
154-
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs, metrics)
152+
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs)
153+
154+
metrics.set_dimensions(
155+
{
156+
"net_devices": str(test_setup.nets),
157+
"block_devices": str(test_setup.blocks),
158+
"vsock_devices": str(int(test_setup.all_devices)),
159+
"balloon_devices": str(int(test_setup.all_devices)),
160+
"huge_pages_config": str(test_setup.huge_pages),
161+
"performance_test": "test_post_restore_latency",
162+
"uffd_handler": str(uffd_handler),
163+
**vm.dimensions,
164+
}
165+
)
155166

156167
vm.ssh.check_output(
157168
"nohup /usr/local/bin/fast_page_fault_helper >/dev/null 2>&1 </dev/null &"
@@ -163,13 +174,6 @@ def test_post_restore_latency(
163174
snapshot = vm.snapshot_full()
164175
vm.kill()
165176

166-
metrics.put_dimensions(
167-
{
168-
"performance_test": "test_post_restore_latency",
169-
"uffd_handler": str(uffd_handler),
170-
}
171-
)
172-
173177
for microvm in microvm_factory.build_n_from_snapshot(
174178
snapshot, ITERATIONS, uffd_handler_name=uffd_handler
175179
):
@@ -191,14 +195,24 @@ def test_population_latency(
191195
):
192196
"""Collects population latency metrics (e.g. how long it takes UFFD handler to fault in all memory)"""
193197
test_setup = SnapshotRestoreTest(mem=128, vcpus=1, huge_pages=huge_pages)
194-
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs, metrics)
195-
snapshot = vm.snapshot_full()
196-
vm.kill()
198+
vm = test_setup.boot_vm(microvm_factory, guest_kernel_linux_5_10, rootfs)
197199

198-
metrics.put_dimensions(
199-
{"performance_test": "test_population_latency", "uffd_handler": "fault_all"}
200+
metrics.set_dimensions(
201+
{
202+
"net_devices": str(test_setup.nets),
203+
"block_devices": str(test_setup.blocks),
204+
"vsock_devices": str(int(test_setup.all_devices)),
205+
"balloon_devices": str(int(test_setup.all_devices)),
206+
"huge_pages_config": str(test_setup.huge_pages),
207+
"performance_test": "test_population_latency",
208+
"uffd_handler": "fault_all",
209+
**vm.dimensions,
210+
}
200211
)
201212

213+
snapshot = vm.snapshot_full()
214+
vm.kill()
215+
202216
for microvm in microvm_factory.build_n_from_snapshot(
203217
snapshot, ITERATIONS, uffd_handler_name="fault_all"
204218
):

0 commit comments

Comments
 (0)