Skip to content

Commit 6f25de3

Browse files
committed
Update 0.7.2
1 parent 2562e26 commit 6f25de3

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

.github/workflows/perf.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
name: Perf
22

33
on:
4-
schedule:
5-
# Sunday 02:00 UTC
6-
- cron: "0 2 * * 0"
7-
# Wednesday 02:00 UTC
8-
- cron: "0 2 * * 3"
4+
# Manual trigger only by default; set ENABLE_PERF to true to enable scheduled runs
95
workflow_dispatch: {}
6+
schedule:
7+
# Disabled by default via job-level gate; enable by setting ENABLE_PERF to 'true'
8+
- cron: "0 2 * * 0" # Sunday 02:00 UTC
9+
- cron: "0 2 * * 3" # Wednesday 02:00 UTC
10+
11+
env:
12+
# Gate to disable perf by default in CI. Set to 'true' to enable.
13+
ENABLE_PERF: "false"
1014

1115
jobs:
1216
perf-tests:
1317
name: Perf Tests and Benches
1418
runs-on: ubuntu-latest
15-
# Only run on main branch for scheduled/manual invocations
16-
if: github.ref_name == 'main'
19+
# Only run when explicitly enabled and on main branch for scheduled/manual invocations
20+
if: ${{ env.ENABLE_PERF == 'true' && github.ref_name == 'main' }}
1721
concurrency:
1822
group: perf-${{ github.ref }}
1923
cancel-in-progress: false
@@ -64,6 +68,8 @@ jobs:
6468
find target/criterion -maxdepth 2 -type d -print || true
6569
6670
- name: Compare Criterion results to baselines (watch_timer_hot)
71+
env:
72+
PERF_COMPARE_STRICT: "0"
6773
run: |
6874
if [ ! -d target/criterion ]; then
6975
echo "No Criterion results found; skipping watch_timer_hot baseline comparison.";
@@ -85,6 +91,8 @@ jobs:
8591
--save-baseline current
8692
8793
- name: Compare Criterion results to baselines (timers)
94+
env:
95+
PERF_COMPARE_STRICT: "0"
8896
run: |
8997
if [ ! -d target/criterion ]; then
9098
echo "No Criterion results found; skipping timers baseline comparison.";
@@ -106,6 +114,8 @@ jobs:
106114
--save-baseline current
107115
108116
- name: Compare Criterion results to baselines (histogram_hot)
117+
env:
118+
PERF_COMPARE_STRICT: "0"
109119
run: |
110120
if [ ! -d target/criterion ]; then
111121
echo "No Criterion results found; skipping histogram_hot baseline comparison.";

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
- Bench workflow `.github/workflows/bench.yml`: use `examples/zero_overhead.rs` for the no-default-features run, and keep `overhead_compare` for the enabled run to avoid feature gating conflicts.
2020
- Module order clean-up in `src/lib.rs` to satisfy Code Quality check (place `mod trace;` after `mod timer;`).
2121
- Documentation consistency sweep: ensure install snippets reference `0.7.1` across `docs/` feature pages and API.
22+
- Perf workflow `.github/workflows/perf.yml`: gated behind `ENABLE_PERF` (default `false`) so perf does not run by default in CI; comparison steps include pre-checks and run in lenient mode by default.
23+
- Baseline comparator `scripts/compare_criterion_baseline.sh`: made non-fatal when Criterion output is absent or no baseline keys match; add `PERF_COMPARE_STRICT=1` to enforce strict behavior. Defaults to lenient; workflow passes `PERF_COMPARE_STRICT=0`.
2224

2325

2426
<br>

scripts/compare_criterion_baseline.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,32 @@ if [[ -d "target/criterion/${GROUP_NAME}" ]]; then
3232
elif [[ -d "target/criterion" ]]; then
3333
BASE_DIR="target/criterion"
3434
else
35-
echo "error: criterion directory not found: target/criterion" >&2
36-
exit 2
35+
echo "note: criterion directory not found: target/criterion — skipping baseline comparison" >&2
36+
echo "Baseline comparison skipped."
37+
exit 0
3738
fi
3839

3940
# Optional: show which layout is used (useful in CI logs)
4041
echo "Using Criterion base directory: ${BASE_DIR}" >&2
4142

4243
fail_count=0
44+
found_count=0
45+
total_count=0
46+
missing_count=0
4347

4448
# Iterate baseline entries: key, median_s, tolerance
4549
while IFS=$'\t' read -r KEY MEDIAN_S TOL; do
4650
# Build path to criterion estimates for this key
51+
total_count=$((total_count + 1))
52+
4753
EST_PATH="${BASE_DIR}/${KEY}/new/estimates.json"
4854
if [[ ! -f "${EST_PATH}" ]]; then
4955
echo "missing estimates: ${EST_PATH}" >&2
50-
fail_count=$((fail_count + 1))
56+
missing_count=$((missing_count + 1))
57+
# Only fail on missing when strict mode is enabled
58+
if [[ "${PERF_COMPARE_STRICT:-}" == "1" ]]; then
59+
fail_count=$((fail_count + 1))
60+
fi
5161
continue
5262
fi
5363

@@ -81,6 +91,8 @@ PY
8191
BASE_P=$(pretty "${MEDIAN_S}")
8292
ALWD_P=$(pretty "${ALLOWED}")
8393

94+
found_count=$((found_count + 1))
95+
8496
if [[ "${OK}" == "1" ]]; then
8597
echo "OK ${KEY} actual=${ACT_P} baseline=${BASE_P} tol=${TOL} allowed<=${ALWD_P}"
8698
else
@@ -90,8 +102,14 @@ PY
90102

91103
done < <(jq -r 'to_entries[] | [ .key, .value.median_s, .value.tolerance ] | @tsv' "${BASELINE_JSON}")
92104

105+
if [[ ${found_count} -eq 0 ]]; then
106+
echo "note: no matching Criterion results were found for any baseline keys (total=${total_count}, missing=${missing_count})." >&2
107+
echo "Baseline comparison skipped."
108+
exit 0
109+
fi
110+
93111
if [[ ${fail_count} -gt 0 ]]; then
94-
echo "Baseline comparison failed: ${fail_count} regression(s) detected." >&2
112+
echo "Baseline comparison failed: ${fail_count} regression(s) detected. (checked=${found_count}, missing=${missing_count}, total=${total_count})" >&2
95113
exit 1
96114
fi
97115

0 commit comments

Comments
 (0)