fix: keep the host awake during bench runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 07:25:20 +03:00
co-authored by Claude Opus 5.5
parent 4be2316bf8
commit 67cb4d7d9a
5 changed files with 63 additions and 6 deletions
+12
View File
@@ -69,6 +69,8 @@ SUCCESS_METRIC = "http_req_duration{expected_response:true}"
SWAP_WARN_MIB = 1024
# предупреждение о VM: лимиты памяти стенда + этот запас больше памяти VM
VM_RESERVE_GIB = 1.5
# предупреждение о хосте: реальное время прогона больше монотонного, с
SLEEP_WARN_S = 5
# psql в контейнере Postgres от пользователя образа, без пароля; SQL — stdin
PSQL = (
'exec psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -XAtq -v ON_ERROR_STOP=1'
@@ -2903,6 +2905,10 @@ def main(argv: list[str]) -> int:
}
stand_check = Stand(profile, label_dir)
started = time.monotonic()
# на macOS монотонные часы во сне стоят, а реальные идут: разница —
# сколько хост проспал посреди прогона (решение 9 design change
# track2-backup-restore)
started_wall = time.time()
def say(text: str) -> None:
elapsed = int(time.monotonic() - started)
@@ -2954,6 +2960,12 @@ def main(argv: list[str]) -> int:
shutil.rmtree(bench.stand.work_dir, ignore_errors=True)
meta["finished_at"] = datetime.now(UTC).isoformat(timespec="seconds")
meta["host_state"]["end"] = host_state()
slept = (time.time() - started_wall) - (time.monotonic() - started)
meta["host_state"]["slept_seconds"] = round(max(0.0, slept))
if slept > SLEEP_WARN_S:
warning = f"host slept {slept:.0f}s during the run: rerun"
meta["host_warnings"].append(warning)
say(f"WARNING: {warning}")
results.write_meta()
results.write_summary()
bench.stage = "done" if code == 0 else meta.get("reason", "stopped")