Skip to content

Commit 0ce8a35

Browse files
committed
feat(tests): add systemd_analyze data as boot time metric
Currently we measure boottime by looking at the Firecracker logs and waiting for the guest to trigger a special boot device inside Firecracker. There is an alternative way of measuring boot time from a guest perspective by using systemd-analyze. Will help us to understand boot times better. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 321b26a commit 0ce8a35

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/integration_tests/performance/test_boottime.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ def find_events(log_data):
6969
return timestamps
7070

7171

72+
def get_systemd_analyze_times(microvm):
73+
"""
74+
Parse systemd-analyze output
75+
"""
76+
rc, stdout, stderr = microvm.ssh.run("systemd-analyze")
77+
assert rc == 0, stderr
78+
assert stderr == ""
79+
80+
boot_line = stdout.splitlines()[0]
81+
pattern = r"Startup finished in (.*)\s+\(kernel\) \+ (.*)\s+\(userspace\) = (.*)\s*"
82+
kernel, userspace, total = re.findall(pattern, boot_line)[0]
83+
84+
def to_ms(v):
85+
if "ms" not in v:
86+
return int(v.strip()[:-1]) * 1000
87+
else:
88+
return int(v.strip()[:-2])
89+
90+
kernel = to_ms(kernel)
91+
userspace = to_ms(userspace)
92+
total = to_ms(total)
93+
94+
return kernel, userspace, total
95+
96+
7297
@pytest.mark.parametrize(
7398
"vcpu_count,mem_size_mib",
7499
[(1, 128), (1, 1024), (2, 2048), (4, 4096)],
@@ -112,4 +137,10 @@ def test_boottime(
112137
boottime_us - build_time.microseconds,
113138
unit="Microseconds",
114139
)
140+
141+
kernel, userspace, total = get_systemd_analyze_times(vm)
142+
metrics.put_metric("systemd_kernel", kernel, unit="Milliseconds")
143+
metrics.put_metric("systemd_userspace", userspace, unit="Milliseconds")
144+
metrics.put_metric("systemd_total", total, unit="Milliseconds")
145+
115146
vm.kill()

0 commit comments

Comments
 (0)