Skip to content

Commit de32f60

Browse files
authored
fix: lag ratio guards only engage when churn latency is actually slow (#80)
The p95/avg ratio caps fired repeatedly today on runs whose absolute latency was excellent (churn p95 of 13-17ms against a 35ms cap) because a fast baseline (~6-8ms) makes the ratio hypersensitive to a few ms of runner jitter. Six unrelated PRs burned manual re-runs on this. Ratio enforcement now additionally requires the churn result itself to be slow (p95 >= 20ms, avg >= 14ms by default, env-tunable). Real regressions on fast baselines remain caught by the untouched delta caps (+20ms p95 / +12ms avg) and absolute cap (35ms p95): a genuine 3x regression from a 7ms baseline blows the delta cap regardless.
1 parent fad9058 commit de32f60

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

tests/test_workspace_churn_up_arrow_lag.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
MAX_AVG_DELTA_MS = float(os.environ.get("PROGRAMA_LAG_MAX_AVG_DELTA_MS", "12.0"))
5858
MIN_BASELINE_P95_MS_FOR_RATIO = float(os.environ.get("PROGRAMA_LAG_MIN_BASELINE_P95_MS_FOR_RATIO", "6.0"))
5959
MIN_BASELINE_AVG_MS_FOR_RATIO = float(os.environ.get("PROGRAMA_LAG_MIN_BASELINE_AVG_MS_FOR_RATIO", "4.0"))
60+
# Ratios are only meaningful when the churn result is actually slow: on fast
61+
# baselines (~6-8ms p95) a few ms of runner jitter doubles the ratio while
62+
# absolute latency stays excellent. Below these churn floors, the delta and
63+
# absolute caps still guard real regressions (a genuine 3x regression from a
64+
# 7ms baseline blows the 20ms p95 delta cap anyway).
65+
MIN_CHURN_P95_MS_FOR_RATIO = float(os.environ.get("PROGRAMA_LAG_MIN_CHURN_P95_MS_FOR_RATIO", "20.0"))
66+
MIN_CHURN_AVG_MS_FOR_RATIO = float(os.environ.get("PROGRAMA_LAG_MIN_CHURN_AVG_MS_FOR_RATIO", "14.0"))
6067
MAX_CPU_PERCENT = float(os.environ.get("PROGRAMA_LAG_MAX_CPU_PERCENT", "180.0"))
6168
ENFORCE_CPU = os.environ.get("PROGRAMA_LAG_ENFORCE_CPU", "0") == "1"
6269
ALLOW_MAIN_SOCKET = os.environ.get("PROGRAMA_LAG_ALLOW_MAIN_SOCKET", "0") == "1"
@@ -459,17 +466,25 @@ def main() -> int:
459466
avg_ratio = churn.avg_ms / max(baseline.avg_ms, 0.001)
460467
p95_delta_ms = churn.p95_ms - baseline.p95_ms
461468
avg_delta_ms = churn.avg_ms - baseline.avg_ms
462-
enforce_p95_ratio = baseline.p95_ms >= MIN_BASELINE_P95_MS_FOR_RATIO
463-
enforce_avg_ratio = baseline.avg_ms >= MIN_BASELINE_AVG_MS_FOR_RATIO
469+
enforce_p95_ratio = (
470+
baseline.p95_ms >= MIN_BASELINE_P95_MS_FOR_RATIO
471+
and churn.p95_ms >= MIN_CHURN_P95_MS_FOR_RATIO
472+
)
473+
enforce_avg_ratio = (
474+
baseline.avg_ms >= MIN_BASELINE_AVG_MS_FOR_RATIO
475+
and churn.avg_ms >= MIN_CHURN_AVG_MS_FOR_RATIO
476+
)
464477

465478
print("\nComparison")
466479
print(
467480
f" p95_ratio: {p95_ratio:.2f}x (max {MAX_P95_RATIO:.2f}x, "
468-
f"enabled when baseline p95 >= {MIN_BASELINE_P95_MS_FOR_RATIO:.2f}ms)"
481+
f"enabled when baseline p95 >= {MIN_BASELINE_P95_MS_FOR_RATIO:.2f}ms "
482+
f"and churn p95 >= {MIN_CHURN_P95_MS_FOR_RATIO:.2f}ms)"
469483
)
470484
print(
471485
f" avg_ratio: {avg_ratio:.2f}x (max {MAX_AVG_RATIO:.2f}x, "
472-
f"enabled when baseline avg >= {MIN_BASELINE_AVG_MS_FOR_RATIO:.2f}ms)"
486+
f"enabled when baseline avg >= {MIN_BASELINE_AVG_MS_FOR_RATIO:.2f}ms "
487+
f"and churn avg >= {MIN_CHURN_AVG_MS_FOR_RATIO:.2f}ms)"
473488
)
474489
print(f" churn_p95_ms: {churn.p95_ms:.2f} (max {MAX_CHURN_P95_MS:.2f})")
475490
print(f" p95_delta_ms: {p95_delta_ms:.2f} (max {MAX_P95_DELTA_MS:.2f})")

0 commit comments

Comments
 (0)