mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-11-22 08:17:28 +00:00
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".
This commit is contained in:
parent
cd8b274f89
commit
217b522ec3
@ -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",
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user