refactor: one load threshold for every probe

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:33 +01:00
1 parent 91e385598e
commit eddb26f104
5 files changed
+32 -8

No files matched your search

+6 -1
View File
@@ -1587,8 +1587,13 @@ def probe(args: argparse.Namespace) -> int:
return _probe(args)
def default_max_load(cpus: int | None = None) -> float:
"""The load above which a run records nothing without --max-load: a quarter of the CPUs."""
return (cpus if cpus is not None else os.cpu_count() or 1) / 4
def _probe(args: argparse.Namespace) -> int:
max_load = args.max_load if args.max_load is not None else (os.cpu_count() or 1) / 4
max_load = args.max_load if args.max_load is not None else default_max_load()
load_before = load_average()
if args.record and load_before and load_before[0] > max_load:
print(f"ERROR: load average {load_before[0]} exceeds {max_load}: the machine is busy, "
+1 -1
View File
@@ -125,7 +125,7 @@ class Host:
@property
def max_load(self) -> float:
return self.cpu_count / 4
return core_probe.default_max_load(self.cpu_count)
def parse_budget(text: str) -> float:
+4 -4
View File
@@ -13,8 +13,8 @@ from collections.abc import Iterable, Sequence
from dataclasses import dataclass
from pathlib import Path
from core_probe import (EXIT_BUSY, PROBE_LOCK_ENV, PROBE_LOCK_HELD_ENV, VERDICTS, head_commit, host_probe_lock,
probe_lock_path)
from core_probe import (EXIT_BUSY, PROBE_LOCK_ENV, PROBE_LOCK_HELD_ENV, VERDICTS, default_max_load, head_commit,
host_probe_lock, probe_lock_path)
from core.paths import REPO_ROOT
from core.statefile import now_iso
from model import measurements as mr
@@ -256,9 +256,9 @@ def content_folder(content: Content, fetch: bool) -> Path:
# --------------------------------------------------------------------------
def wait_idle(limit: float = IDLE_WAIT, poll: float = 30.0) -> None:
"""Wait for the load core_probe records under, a quarter of the CPUs.
"""Wait for the load core_probe records under (core_probe.default_max_load).
Extracting a pack loads the host itself for a minute or two."""
threshold = (os.cpu_count() or 1) / 4
threshold = default_max_load()
waited = 0.0
while os.getloadavg()[0] > threshold:
if waited >= limit:
+1 -2
View File
@@ -3,7 +3,6 @@
from __future__ import annotations
import argparse
import os
import re
import shutil
import subprocess
@@ -101,7 +100,7 @@ def measure(args: argparse.Namespace, emu: Emulator) -> dict:
meta, tree = installed(emu, args.sha256)
except (cp.ProbeError, OSError, subprocess.SubprocessError) as exc:
raise RunFailed(exc) from exc
max_load = args.max_load if args.max_load is not None else (os.cpu_count() or 1) / 4
max_load = args.max_load if args.max_load is not None else cp.default_max_load()
load_before = cp.load_average()
if args.record and load_before and load_before[0] > max_load:
raise Busy(f"load average {load_before[0]} exceeds {max_load}: the machine is busy, "