From 18238588b47ca6f00722a297141ff4a05348aef2 Mon Sep 17 00:00:00 2001 From: roman Date: Tue, 13 Oct 2026 16:15:25 +0300 Subject: [PATCH] fix: record a zero swap-out delta in bench passports Co-Authored-By: Claude Opus 5.5 --- bench/run.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bench/run.py b/bench/run.py index 73db3f6a..78f62679 100644 --- a/bench/run.py +++ b/bench/run.py @@ -928,12 +928,22 @@ def host_warnings(state: dict[str, Any]) -> list[str]: return warnings +def swapouts_delta(start: dict[str, Any], end: dict[str, Any]) -> int | None: + """Прирост выгрузок в swap за прогон: None, если одного из счётчиков + нет; иначе разность, в том числе 0 (счётчик 0 после перезагрузки — + тоже значение, design change `fix-known-issues`, решение 13).""" + before, after = start.get("swapouts"), end.get("swapouts") + if before is None or after is None: + return None + return after - before + + def swap_warning(start: dict[str, Any], end: dict[str, Any]) -> str | None: """Выгрузка в swap за прогон: счётчик вырос — предупреждение.""" - before, after = start.get("swapouts"), end.get("swapouts") - if before is None or after is None or after <= before: + delta = swapouts_delta(start, end) + if delta is None or delta <= 0: return None - return f"host swapped out {after - before} pages during the run: rerun" + return f"host swapped out {delta} pages during the run: rerun" def vm_warnings(profile: Profile) -> list[str]: @@ -5821,10 +5831,9 @@ def main(argv: list[str]) -> int: if swapped is not None: meta["host_warnings"].append(swapped) say(f"WARNING: {swapped}") - if state.get("swapouts") is not None and end_state.get("swapouts"): - meta["host_state"]["swapouts_delta"] = ( - end_state["swapouts"] - state["swapouts"] - ) + delta = swapouts_delta(state, end_state) + if delta is not None: + meta["host_state"]["swapouts_delta"] = delta slept = (time.time() - started_wall) - (time.monotonic() - started) meta["host_state"]["slept_seconds"] = round(max(0.0, slept)) if slept > SLEEP_WARN_S: