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: