A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
tools: measure the boot once more after a settle before refusing (Fixes #2921) (#2923)
Beri585dc9f408d2
diff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex 628ed0bb4..2c17e99f5 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -239,7 +239,9 @@ The gates, in order. The first one that fails ends the night as REFUSED, and notboot the machine settles: the job waits until the 1-minute load average is under 2.0, at most 5 minutes, andmeasures anyway if it never gets there. Each `boot-N.log` starts with the machine's load averages,`vm.swapusage`, `memory_pressure`'s free percentage and `pmset -g therm`, and `boot-1.log` also says how long- the wait took.+ the wait took. A median over the bound is measured once more: the machine settles again, three more boots run+ (`boot-4.log` to `boot-6.log`), and the night is refused only if that second median is also over the bound,+ naming both. The log records both medians when the second one passes (#2921).A nightly never moves a golden: golden moves arrive through reviewed pull requests, and the nightly only needs thegolden tests of the full run to pass.diff --git a/tools/nightly.py b/tools/nightly.pyindex f0c7c10a4..5d911e6cb 100644--- a/tools/nightly.py+++ b/tools/nightly.py@@ -617,19 +617,21 @@ def settle(runner: Runner, cwd: Path, sleep: Callable[[float], None]) -> str:waited += SETTLE_POLL_S-def measure_boot(night: Night, runner: Runner, build: Path, *, sleep: Callable[[float], None] = time.sleep) -> float:+def measure_boot(night: Night, runner: Runner, build: Path, *, sleep: Callable[[float], None] = time.sleep,+ boots: tuple[int, int, int] = (1, 2, 3)) -> float:"""The median of three headless boots, each alone on the machine (no other Unity, no other check), the first- after the machine settles. Each boot-N.log starts with the machine's state, read just before that boot."""+ after the machine settles. Each boot-N.log starts with the machine's state, read just before that boot; `boots`+ numbers the logs, so a re-measure (#2921) keeps the first three."""clone = night.cfg.cloneruns: list[int] = []settled = settle(runner, night.cfg.main_repo, sleep)- for i in (1, 2, 3):+ for i in boots:argv = ["uv", "run", str(clone / "tools/machine_lock.py"), "--exclusive", "--wait-unity", "--timeout", "2700","--", "uv", "run", str(clone / "tools/web_check.py"), str(build), "--query", "bootlog","--expect", "GAME OK", "--timeout", "300", "--stall", "90"]log = night.run_dir / f"boot-{i}.log"try:- header = machine_state(runner, night.cfg.main_repo) + ([settled] if i == 1 else [])+ header = machine_state(runner, night.cfg.main_repo) + ([settled] if i == boots[0] else [])log.write_text("\n".join(header) + "\n", encoding="utf-8") # the runner appends the boot after itcode = runner.run(argv, cwd=night.cfg.main_repo, log=log, deadline=_limit(night, 60))except (OSError, subprocess.SubprocessError) as error:@@ -648,6 +650,23 @@ def measure_boot(night: Night, runner: Runner, build: Path, *, sleep: Callable[[return float(statistics.median(runs))+def boot_gate(night: Night, state: State, runner: Runner, build: Path) -> tuple[float, str]:+ """measure_boot's median against the bound. A median over it gets one re-measure after the machine settles again+ (the owner's ruling on #2921: v0.3.8 was refused at 6313 ms and then booted in about 4450 ms), and only a second+ median over the bound refuses. Returns the median the night passed with and the verdict's phase."""+ boot = measure_boot(night, runner, build)+ phase, why = nightly_checks.boot_verdict(boot, state.boot_baseline, BASELINE_NIGHTS)+ if why is None:+ return boot, phase+ print(f"boot: {why}; settling and measuring once more (boot-4..6.log)")+ again = measure_boot(night, runner, build, boots=(4, 5, 6))+ phase, why_again = nightly_checks.boot_verdict(again, state.boot_baseline, BASELINE_NIGHTS)+ if why_again:+ raise Refused("boot", f"{why}; measured again after settling: {why_again}")+ print(f"boot: first median {boot:.0f} ms was over the bound; re-measure after settling: {again:.0f} ms, under it")+ return again, phase++# --- publishing -------------------------------------------------------------------------------------------------def previous_build(night: Night, state: State, gh: GitHub, runner: Runner) -> tuple[str, str | None]:@@ -970,10 +989,7 @@ def run_stages(night: Night, state: State, runner: Runner, gh: GitHub, itch, *,prev_tag, prev_sha = previousprevious_zip = gh.download(prev_tag, "*-web.zip", night.run_dir / "previous")sizes = check_sizes(night, gh, gz, previous_zip, prev_sha, runner=runner)- boot = measure_boot(night, runner, gz)- phase, why = nightly_checks.boot_verdict(boot, state.boot_baseline, BASELINE_NIGHTS)- if why:- raise Refused("boot", why)+ boot, phase = boot_gate(night, state, runner, gz)print(f"boot: {boot:.0f} ms ({phase}, {len(state.boot_baseline)} baseline nights)")if no_publish:print(f"NO-PUBLISH: all gates passed for {night.tag}")diff --git a/tools/tests/test_nightly.py b/tools/tests/test_nightly.pyindex ffb05c523..fc3c5ac4b 100644--- a/tools/tests/test_nightly.py+++ b/tools/tests/test_nightly.py@@ -1237,6 +1237,38 @@ def test_unreadable_machine_state_never_changes_the_verdict(night, env):assert "settle: 1-minute load unreadable, not waiting" in first+# #2921: one over-bound median gets one re-measure after the machine settles again; only a second one refuses.+BOOT_BASELINE = [4400.0, 4450.0, 4500.0, 4400.0, 4450.0] # bound 4500 + 100 = 4600 ms+++def test_a_first_median_under_the_bound_takes_no_second_measurement(night, env):+ r = boot_runner([4400, 4500, 4450])+ st = ns.State(boot_baseline=list(BOOT_BASELINE))+ assert nightly.boot_gate(night, st, r, night.cfg.clone / "unity/Builds/Web-gzip") == (4450.0, "checked")+ assert len(r.calls) == 3 and not (night.run_dir / "boot-4.log").exists()+++def test_an_over_bound_median_then_one_under_it_passes_and_the_log_records_both(night, env, capsys):+ r = boot_runner([6300, 6313, 6320, 4440, 4450, 4460])+ st = ns.State(boot_baseline=list(BOOT_BASELINE))+ assert nightly.boot_gate(night, st, r, night.cfg.clone / "unity/Builds/Web-gzip") == (4450.0, "checked")+ assert len(r.calls) == 6+ out = capsys.readouterr().out+ assert "6313 ms, over the 4600 ms bound" in out and "re-measure after settling: 4450 ms" in out+ again = [(night.run_dir / f"boot-{i}.log").read_text() for i in (4, 5, 6)]+ assert "settle: 1-minute load 0.80 under 2.0" in again[0] and "settle:" not in again[1]+ assert boot_logs(night)[1].count("BOOT phase") == 1 # the first three logs are kept, not overwritten+++def test_two_over_bound_medians_refuse_naming_both(night, env):+ r = boot_runner([6300, 6313, 6320, 6280, 6290, 6270])+ st = ns.State(boot_baseline=list(BOOT_BASELINE))+ with pytest.raises(Refused) as e:+ nightly.boot_gate(night, st, r, night.cfg.clone / "unity/Builds/Web-gzip")+ assert e.value.gate == "boot" and len(r.calls) == 6+ assert "6313 ms, over the 4600 ms bound" in e.value.detail and "6280 ms, over the 4600 ms bound" in e.value.detail++# --- Task 6: publish_night, the stage wiring, the clients ---------------------------------------------------------BOOT_MS = 8200.0