From 217b522ec345d3ed7c8276cb1c2220b9514853c5 Mon Sep 17 00:00:00 2001 From: Jozef Koval Date: Thu, 24 Sep 2026 22:34:02 +0200 Subject: [PATCH] Fail the floor gate on a benchmark with no floor The gate fails when a floored benchmark stops reporting (exit 3, no retry) so that a benchmark cannot be dropped without an explicit floors-file change. The other direction was advisory: a benchmark that reports a PERF line with no floor printed "consider adding a floor" into the job log and passed. Nothing else surfaces that line, so a new hot-path benchmark could measure on every run and guard nothing, and the file the gate reads would still look complete. That is the shape of the localization gap closed in #1654, where a key missing from every catalog compiled and shipped English while CI stayed green, and the move is the one made in #1646 and #1648: an advisory check becomes blocking once its backlog is zero. perf-floors.json carries 12 floors and PerformanceBaselineTests has 12 benchmarks, so flipping this costs nothing today and holds the two in step from now on. An unfloored benchmark now fails alongside a missing one, with the same exit code and for the same reason: the floors file and the benchmark suite must change together, and no re-measurement can repair a drift between them. The message names the file to edit. The test pinned in the previous commit flips from "reported but does not fail" to "fails without a retry"; the philosophy note in the floors file says "added, renamed or removed" instead of "renamed or removed". --- bitchatTests/Performance/perf-floors.json | 5 +++-- scripts/check-perf-floors.sh | 18 +++++++++++------- scripts/tests/test_check_perf_floors.py | 11 +++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/bitchatTests/Performance/perf-floors.json b/bitchatTests/Performance/perf-floors.json index 751caf74..3fa9b246 100644 --- a/bitchatTests/Performance/perf-floors.json +++ b/bitchatTests/Performance/perf-floors.json @@ -12,8 +12,9 @@ "magnitude regressions while never flaking on a slow runner.", "Raise floors deliberately after intentional performance improvements;", "lower them only with a written justification in the PR. If a benchmark is", - "renamed or removed, update this file in the same change - the gate fails", - "when a floored benchmark stops reporting.", + "added, renamed or removed, update this file in the same change - the gate", + "fails when a floored benchmark stops reporting or when a benchmark reports", + "with no floor.", "Checked by scripts/check-perf-floors.sh against captured swift-test output." ], "_units": "operations per second, matching each benchmark's PERF line", diff --git a/scripts/check-perf-floors.sh b/scripts/check-perf-floors.sh index b51eb390..71e1dc57 100755 --- a/scripts/check-perf-floors.sh +++ b/scripts/check-perf-floors.sh @@ -36,9 +36,10 @@ # Fails when: # - any benchmark reports throughput below its floor on every attempt # (exit 1), or -# - PERF lines are present but a floored benchmark is missing — a -# silently-dropped benchmark must be an explicit floors-file change and -# is not retried (exit 3). +# - PERF lines are present but a floored benchmark is missing, or a +# benchmark reports with no floor — the floors file and the benchmark +# suite must change together in both directions, and neither drift is +# retried (exit 3). set -euo pipefail @@ -111,6 +112,7 @@ with open(output_file, errors="replace") as f: below_floor = [] missing = [] +unfloored = [] print(f"perf-floors: checking {len(measured)} benchmark(s) against {len(floors)} floor(s)") for name in sorted(set(floors) | set(measured)): floor = floors.get(name) @@ -121,7 +123,9 @@ for name in sorted(set(floors) | set(measured)): continue value, unit = measured[name] if floor is None: - print(f" NO-FLOOR {name}: {value:.0f} {unit}/sec (consider adding a floor)") + unfloored.append( + f" NO-FLOOR {name}: {value:.0f} {unit}/sec reports a PERF line but has " + f"no floor (add one to perf-floors.json in the same change)") continue status = "OK" if value >= floor else "BELOW" line = f" {status:8} {name}: {value:.0f} {unit}/sec (floor {floor})" @@ -131,9 +135,9 @@ for name in sorted(set(floors) | set(measured)): f" BELOW {name}: {value:.0f} {unit}/sec is under floor {floor} " f"({value / floor * 100:.0f}% of floor)") -if missing: - print("\nperf-floors: FAILED — floored benchmark(s) missing from the output:") - print("\n".join(missing + below_floor)) +if missing or unfloored: + print("\nperf-floors: FAILED — floors and benchmarks are out of step:") + print("\n".join(missing + unfloored + below_floor)) sys.exit(3) if below_floor: diff --git a/scripts/tests/test_check_perf_floors.py b/scripts/tests/test_check_perf_floors.py index 156d7dba..ecbdcdf9 100644 --- a/scripts/tests/test_check_perf_floors.py +++ b/scripts/tests/test_check_perf_floors.py @@ -133,17 +133,16 @@ class CheckPerfFloorsTests(unittest.TestCase): self.assertEqual(self.remeasure_count(), 0) self.assertIn("MISSING b.two: floored benchmark reported no PERF line", result.stdout) - def test_unfloored_benchmark_is_reported_but_does_not_fail(self) -> None: - # Pinned as found, not endorsed: the gate fails when a floored - # benchmark stops reporting, but a benchmark that reports with no floor - # only prints advice. That asymmetry is the subject of the follow-up. + def test_unfloored_benchmark_fails_without_a_retry(self) -> None: + # The mirror of the missing case: a benchmark that measures but has no + # floor guards nothing, and no re-measurement can supply the floor. result = self.run_gate( self.log("PERF[a.one]: 1000 ops/sec", "PERF[c.new]: 1000 ops/sec"), self.floors(**{"a.one": 100}), ) - self.assertEqual(result.returncode, 0, result.stdout + result.stderr) - self.assertIn("NO-FLOOR c.new: 1000 ops/sec (consider adding a floor)", result.stdout) + self.assertEqual(result.returncode, 3, result.stdout + result.stderr) + self.assertIn("NO-FLOOR c.new: 1000 ops/sec reports a PERF line but has no floor", result.stdout) self.assertEqual(self.remeasure_count(), 0) def test_output_without_perf_lines_skips(self) -> None: