Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions scripts/nvx_tools/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
KernelBuildConstants,
OpenVMMBuildConstants,
)
from .common import sha256_file
from .common import bytes_to_mib, sha256_file

BOOT_MARKER = b"ALPINE-MICROVM-BOOT-OK"
RESTORE_MARKER = b"OPENVMM-SNAPSHOT-RESTORE-OK"
Expand Down Expand Up @@ -1201,10 +1201,6 @@ def summarize_lifecycle_profiles(
}


def bytes_to_mib(value: int | float) -> float:
return value / (1024 * 1024)


def terminate(process: subprocess.Popen[bytes]) -> None:
if process.poll() is None:
process.kill()
Expand Down
4 changes: 4 additions & 0 deletions scripts/nvx_tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def remaining_timeout(deadline: float) -> float:
return max(0.0, deadline - time.monotonic())


def bytes_to_mib(value: int | float) -> float:
return value / (1024 * 1024)


def artifact_path(name: str) -> Path:
return BuildConstants.BUILD_DIR / name

Expand Down
9 changes: 5 additions & 4 deletions scripts/nvx_tools/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from pathlib import Path
from typing import cast

from .common import bytes_to_mib

LEGACY_CSV_FIELDS = ["commit", "metric", "unit", "direction", "p50"]
CSV_FIELDS = [
"platform",
Expand Down Expand Up @@ -66,7 +68,6 @@
"openvmm_snapshot_restore_peak_rss",
}
)
BYTES_PER_MIB = 1024 * 1024
LIFECYCLE_MEMORY_MIB = 128
LIFECYCLE_BOOT_MARKER = "ALPINE-MICROVM-BOOT-OK"
LIFECYCLE_RESTORE_MARKER = "OPENVMM-SNAPSHOT-RESTORE-OK"
Expand Down Expand Up @@ -1160,7 +1161,7 @@ def read_lifecycle_data(platform: str, input_path: Path) -> LifecycleData:
metric: (
unit,
"lower",
value / BYTES_PER_MIB if unit == "MiB" else value,
bytes_to_mib(value) if unit == "MiB" else value,
)
for metric, section, field, unit in metric_fields
for value in [_openvmm_value(document, section, backend, field, input_path)]
Expand Down Expand Up @@ -1277,8 +1278,8 @@ def append_openvmm_diagnostics(
document, section, backend, "peak_rss_max_bytes", source
)
lines.append(
f"| {label} | {p50 / BYTES_PER_MIB:.2f} MiB | "
f"{maximum / BYTES_PER_MIB:.2f} MiB |"
f"| {label} | {bytes_to_mib(p50):.2f} MiB | "
f"{bytes_to_mib(maximum):.2f} MiB |"
)
lines.extend(
[
Expand Down
Loading