|
11 | 11 | from framework.properties import global_props
|
12 | 12 |
|
13 | 13 | # Regex for obtaining boot time from some string.
|
14 |
| -TIMESTAMP_LOG_REGEX = r"Guest-boot-time\s+\=\s+(\d+)\s+us" |
15 | 14 |
|
16 | 15 | DEFAULT_BOOT_ARGS = (
|
17 | 16 | "reboot=k panic=1 pci=off nomodule 8250.nr_uarts=0"
|
|
27 | 26 | }
|
28 | 27 |
|
29 | 28 |
|
30 |
| -def _get_microvm_boottime(vm): |
| 29 | +def get_boottime_device_info(vm): |
31 | 30 | """Auxiliary function for asserting the expected boot time."""
|
32 | 31 | boot_time_us = None
|
| 32 | + boot_time_cpu_us = None |
33 | 33 | timestamps = []
|
34 | 34 |
|
| 35 | + timestamp_log_regex = ( |
| 36 | + r"Guest-boot-time =\s+(\d+) us\s+(\d+) ms,\s+(\d+) CPU us\s+(\d+) CPU ms" |
| 37 | + ) |
| 38 | + |
35 | 39 | iterations = 50
|
36 | 40 | sleep_time_s = 0.1
|
37 | 41 | for _ in range(iterations):
|
38 |
| - timestamps = re.findall(TIMESTAMP_LOG_REGEX, vm.log_data) |
| 42 | + timestamps = re.findall(timestamp_log_regex, vm.log_data) |
39 | 43 | if timestamps:
|
40 | 44 | break
|
41 | 45 | time.sleep(sleep_time_s)
|
42 | 46 | if timestamps:
|
43 |
| - boot_time_us = int(timestamps[0]) |
| 47 | + boot_time_us, _, boot_time_cpu_us, _ = timestamps[0] |
44 | 48 |
|
45 |
| - assert boot_time_us, ( |
| 49 | + assert boot_time_us and boot_time_cpu_us, ( |
46 | 50 | f"MicroVM did not boot within {sleep_time_s * iterations}s\n"
|
47 | 51 | f"Firecracker logs:\n{vm.log_data}\n"
|
48 | 52 | f"Thread backtraces:\n{vm.thread_backtraces}"
|
49 | 53 | )
|
50 |
| - return boot_time_us |
| 54 | + return int(boot_time_us), int(boot_time_cpu_us) |
51 | 55 |
|
52 | 56 |
|
53 | 57 | def find_events(log_data):
|
@@ -133,16 +137,22 @@ def test_boottime(
|
133 | 137 | vm.add_net_iface()
|
134 | 138 | vm.start()
|
135 | 139 | vm.pin_threads(0)
|
136 |
| - boottime_us = _get_microvm_boottime(vm) |
137 |
| - metrics.put_metric("boot_time", boottime_us, unit="Microseconds") |
138 |
| - timestamps = find_events(vm.log_data) |
139 |
| - build_time = timestamps["build microvm for boot"]["duration"] |
140 |
| - metrics.put_metric("build_time", build_time.microseconds, unit="Microseconds") |
| 140 | + |
| 141 | + boot_time_us, cpu_boot_time_us = get_boottime_device_info(vm) |
141 | 142 | metrics.put_metric(
|
142 | 143 | "guest_boot_time",
|
143 |
| - boottime_us - build_time.microseconds, |
| 144 | + boot_time_us, |
144 | 145 | unit="Microseconds",
|
145 | 146 | )
|
| 147 | + metrics.put_metric( |
| 148 | + "guest_cpu_boot_time", |
| 149 | + cpu_boot_time_us, |
| 150 | + unit="Microseconds", |
| 151 | + ) |
| 152 | + |
| 153 | + timestamps = find_events(vm.log_data) |
| 154 | + build_time = timestamps["build microvm for boot"]["duration"] |
| 155 | + metrics.put_metric("build_time", build_time.microseconds, unit="Microseconds") |
146 | 156 |
|
147 | 157 | kernel, userspace, total = get_systemd_analyze_times(vm)
|
148 | 158 | metrics.put_metric("systemd_kernel", kernel, unit="Milliseconds")
|
|
0 commit comments