Skip to content

Commit c878c10

Browse files
authored
Merge branch 'main' into mem_overh
2 parents 732d596 + 86afedb commit c878c10

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

.buildkite/pipeline_perf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
"tests": "integration_tests/performance/test_boottime.py::test_boottime",
6666
"devtool_opts": "-c 1-10 -m 0",
6767
},
68+
"process-startup": {
69+
"label": "process-startup",
70+
"tests": "integration_tests/performance/test_process_startup_time.py",
71+
"devtool_opts": "-c 1-10 -m 0",
72+
},
6873
"jailer": {
6974
"label": "jailer",
7075
"tests": "integration_tests/performance/test_jailer.py",

tests/host_tools/cargo_build.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ def get_example(name, *args, package="firecracker", **kwargs):
6969
return get_binary(package, *args, **kwargs, example=name)
7070

7171

72-
def run_seccompiler_bin(bpf_path, json_path=defs.SECCOMP_JSON_DIR, basic=False):
72+
def run_seccompiler_bin(
73+
bpf_path,
74+
json_path=defs.SECCOMP_JSON_DIR,
75+
basic=False,
76+
binary_dir=DEFAULT_BINARY_DIR,
77+
):
7378
"""
7479
Run seccompiler-bin.
7580
@@ -85,7 +90,7 @@ def run_seccompiler_bin(bpf_path, json_path=defs.SECCOMP_JSON_DIR, basic=False):
8590
if basic:
8691
seccompiler_args += " --basic"
8792

88-
seccompiler = get_binary("seccompiler-bin")
93+
seccompiler = get_binary("seccompiler-bin", binary_dir=binary_dir)
8994
utils.check_output(f"{seccompiler} {seccompiler_args}")
9095

9196

tests/integration_tests/performance/test_process_startup_time.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,63 @@
55
import os
66
import time
77

8+
import pytest
9+
810
from host_tools.cargo_build import run_seccompiler_bin
911

12+
ITERATIONS = 100
13+
1014

15+
@pytest.mark.nonci
1116
def test_startup_time_new_pid_ns(
1217
microvm_factory, guest_kernel_linux_5_10, rootfs, metrics
1318
):
1419
"""
1520
Check startup time when jailer is spawned in a new PID namespace.
1621
"""
17-
for _ in range(10):
22+
for _ in range(ITERATIONS):
1823
microvm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
1924
microvm.jailer.new_pid_ns = True
2025
_test_startup_time(microvm, metrics, "new_pid_ns")
2126

2227

28+
@pytest.mark.nonci
2329
def test_startup_time_daemonize(
2430
microvm_factory, guest_kernel_linux_5_10, rootfs, metrics
2531
):
2632
"""
2733
Check startup time when jailer detaches Firecracker from the controlling terminal.
2834
"""
29-
for _ in range(10):
35+
for _ in range(ITERATIONS):
3036
microvm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
3137
_test_startup_time(microvm, metrics, "daemonize")
3238

3339

40+
@pytest.mark.nonci
3441
def test_startup_time_custom_seccomp(
3542
microvm_factory, guest_kernel_linux_5_10, rootfs, metrics
3643
):
3744
"""
3845
Check the startup time when using custom seccomp filters.
3946
"""
40-
for _ in range(10):
47+
for _ in range(ITERATIONS):
4148
microvm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
4249
_custom_filter_setup(microvm)
4350
_test_startup_time(microvm, metrics, "custom_seccomp")
4451

4552

4653
def _test_startup_time(microvm, metrics, test_suffix: str):
54+
test_start_time = time.time()
4755
microvm.spawn()
4856
microvm.basic_config(vcpu_count=2, mem_size_mib=1024)
4957
metrics.set_dimensions(
5058
{**microvm.dimensions, "performance_test": f"test_startup_time_{test_suffix}"}
5159
)
52-
test_start_time = time.time()
5360
microvm.start()
54-
time.sleep(0.4)
61+
datapoints = microvm.get_all_metrics()
5562

56-
# The metrics should be at index 1.
63+
# The metrics should be at index 0.
5764
# Since metrics are flushed at InstanceStart, the first line will suffice.
58-
datapoints = microvm.get_all_metrics()
5965
test_end_time = time.time()
6066
fc_metrics = datapoints[0]
6167
startup_time_us = fc_metrics["api_server"]["process_startup_time_us"]
@@ -68,20 +74,21 @@ def _test_startup_time(microvm, metrics, test_suffix: str):
6874
)
6975

7076
assert cpu_startup_time_us > 0
71-
# Check that startup time is not a huge value
77+
# Check that startup time is not a huge value (overflow)
7278
# This is to catch issues like the ones introduced in PR
7379
# https://github.com/firecracker-microvm/firecracker/pull/4305
7480
test_time_delta_us = (test_end_time - test_start_time) * 1000 * 1000
7581
assert startup_time_us < test_time_delta_us
7682
assert cpu_startup_time_us < test_time_delta_us
7783

78-
metrics.put_metric("startup_time", cpu_startup_time_us, unit="Microseconds")
84+
metrics.put_metric("startup_cpu_time", cpu_startup_time_us, unit="Microseconds")
85+
metrics.put_metric("startup_time", startup_time_us, unit="Microseconds")
7986

8087

8188
def _custom_filter_setup(test_microvm):
8289
bpf_path = os.path.join(test_microvm.path, "bpf.out")
8390

84-
run_seccompiler_bin(bpf_path)
91+
run_seccompiler_bin(bpf_path, binary_dir=test_microvm.fc_binary_path.parent)
8592

8693
test_microvm.create_jailed_resource(bpf_path)
8794
test_microvm.jailer.extra_args.update({"seccomp-filter": "bpf.out"})

0 commit comments

Comments
 (0)