Skip to content

Commit fa4bc7a

Browse files
authored
[MISC] Distinguish large deviation from regression in performance report. (#1999)
1 parent c640d1c commit fa4bc7a

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

.github/workflows/alarm.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
CSV_RUNTIME_PATH: runtime_fps.csv
6666
CSV_COMPILE_PATH: compile_time.csv
6767
EXIT_CODE_REGRESSION: 42
68+
EXIT_CODE_ALERT: 43
6869
run: |
6970
{ python - << 'PY'; EXIT_CODE=$?; } || true
7071
@@ -244,11 +245,11 @@ jobs:
244245
# Parse benchmark IDs into key-value dicts while preserving order
245246
params_name = get_param_names(tuple((tuple(kv.keys())) for kv in current_bm.keys()))
246247
247-
reg_found = False
248+
reg_found, alert_found = False, False
248249
tables = {}
249250
rows_for_csv = {"runtime_fps": [], "compile_time": []}
250251
info = {}
251-
for metric, alias in (("runtime_fps", "FPS"), ("compile_time", "compile")):
252+
for metric, alias, sign in (("runtime_fps", "FPS", 1), ("compile_time", "compile", -1)):
252253
rows_md = []
253254
254255
header_cells = (
@@ -296,12 +297,18 @@ jobs:
296297
297298
value_std = statistics.stdev(values_prev)
298299
stats_repr += f" ({fmt_num(value_ref, is_int)} ± {fmt_num(value_std, is_int)})"
299-
if abs(delta) > METRICS_TOL[metric]:
300-
info["status"] = "alert"
300+
if sign * delta < - METRICS_TOL[metric]:
301+
info["status"] = "regression"
301302
302303
delta_repr = f"**{delta_repr}**"
303304
picto = "🔴"
304305
reg_found = True
306+
elif sign * delta > METRICS_TOL[metric]:
307+
info["status"] = "alert"
308+
309+
delta_repr = f"**{delta_repr}**"
310+
picto = "⚠️"
311+
alert_found = True
305312
else:
306313
info["status"] = "ok"
307314
@@ -364,8 +371,14 @@ jobs:
364371
# write md results
365372
check_body_path.write_text(check_body + "\n", encoding="utf-8")
366373
367-
# Exit with 42 if regressions are found, 0 otherwise
368-
sys.exit(int(os.environ["EXIT_CODE_REGRESSION"]) if reg_found else 0)
374+
# Exit with error code
375+
if reg_found:
376+
exit_code = int(os.environ["EXIT_CODE_REGRESSION"])
377+
elif alert_found:
378+
exit_code = int(os.environ["EXIT_CODE_ALERT"])
379+
else:
380+
exit_code = 0
381+
sys.exit(exit_code)
369382
PY
370383
371384
# Enable command trace to ease debugging
@@ -385,6 +398,7 @@ jobs:
385398
# Export status
386399
echo "CONCLUSION=$([ "$EXIT_CODE" = "0" ] && echo 'success' || echo 'failure')" >> "$GITHUB_ENV"
387400
echo "HAS_REGRESSIONS=$([ "$EXIT_CODE" = "$EXIT_CODE_REGRESSION" ] && echo 1 || echo 0)" >> "$GITHUB_ENV"
401+
echo "HAS_ALERTS=$([ "$EXIT_CODE" = "$EXIT_CODE_ALERT" ] && echo 1 || echo 0)" >> "$GITHUB_ENV"
388402
389403
- name: Upload benchmark comparisons in CSV
390404
id: upload
@@ -404,6 +418,7 @@ jobs:
404418
CHECK_OUTPUT: ${{ env.CHECK_OUTPUT }}
405419
CONCLUSION: ${{ env.CONCLUSION }}
406420
HAS_REGRESSIONS: ${{ env.HAS_REGRESSIONS }}
421+
HAS_ALERTS: ${{ env.HAS_ALERTS }}
407422
ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }}
408423
with:
409424
script: |
@@ -413,9 +428,14 @@ jobs:
413428
body += `\n\n**Artifact:** [Download raw data](${artifactUrl})`;
414429
}
415430
416-
const summary = (process.env.HAS_REGRESSIONS || '0') === '1'
417-
? '🔴 Regressions detected. See tables below.'
418-
: '✅ No regressions detected. See tables below.';
431+
let summary;
432+
if ((process.env.HAS_REGRESSIONS || '0') === '1') {
433+
summary = '🔴 Regressions detected. See tables below.';
434+
} else if ((process.env.HAS_ALERTS || '0') === '1') {
435+
summary = '⚠️ Large deviation detected. See tables below.';
436+
} else {
437+
summary = '✅ No regressions detected. See tables below.';
438+
}
419439
420440
const check = await github.rest.checks.create({
421441
owner: context.repo.owner,
@@ -433,9 +453,10 @@ jobs:
433453
core.setOutput("check-url", check.data.html_url);
434454
435455
- name: Add PR comment
436-
if: ${{ env.HAS_REGRESSIONS == '1' }}
456+
if: ${{ env.HAS_REGRESSIONS == '1' || env.HAS_ALERTS == '1' }}
437457
uses: actions/github-script@v8
438458
env:
459+
HAS_REGRESSIONS: ${{ env.HAS_REGRESSIONS }}
439460
REPORT_URL: ${{ steps.publish_check.outputs.check-url }}
440461
with:
441462
script: |
@@ -452,8 +473,10 @@ jobs:
452473
return;
453474
}
454475
455-
const comment = `:warning: **Benchmark Regression Detected**
456-
➡️ **[Open Benchmark Comparison Report](${process.env.REPORT_URL})**`;
476+
const title = (process.env.HAS_REGRESSIONS || '0') === '1'
477+
? 'Benchmark Regression Detected' : 'Abnormal Benchmark Result Detected';
478+
const comment = `:warning: **${title}**
479+
➡️ **[Report](${process.env.REPORT_URL})**`;
457480
458481
await github.rest.issues.createComment({
459482
owner: context.repo.owner,

0 commit comments

Comments
 (0)