Skip to content

Commit 7f3f6d2

Browse files
yu-medcursoragent
andcommitted
ci: stabilize benchmark gate on noisy micro-benches
Exclude sub-100µs cache lookup benchmarks from the regression gate and refresh baselines from the slower of two CI runs so ubuntu-latest variance stops flipping STALE/REGRESSION on unrelated PRs. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 067d0ee commit 7f3f6d2

3 files changed

Lines changed: 53 additions & 45 deletions

File tree

benchmarks/baselines.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
2-
"_note": "Gated means from ubuntu-latest CI benchmark-results.json. Values multiplied by 1.5x slack at generation time. Excluded from gate (recorded for reference): test_summary_cache_round_trip. Refresh after intentional speedups via reduce_baselines.py.",
3-
"updated": "2026-07-15T16:06:06Z",
2+
"_note": "Gated means from max of two ubuntu-latest CI runs (slow/1.19 margin). Sub-100us cache lookup benches excluded from gate due to runner variance.",
3+
"updated": "2026-07-15T16:14:31Z",
44
"machine": "Linux",
55
"groups": {
66
"parse": {
7-
"test_list_workspace_projects_nocache[composers-10]": 0.011127133119230019,
8-
"test_list_workspace_projects_nocache[composers-50]": 0.04701202616129109,
9-
"test_list_workspace_projects_nocache[composers-200]": 0.15071771933333505
7+
"test_list_workspace_projects_nocache[composers-10]": 0.009873695869187243,
8+
"test_list_workspace_projects_nocache[composers-200]": 0.1458800642857019,
9+
"test_list_workspace_projects_nocache[composers-50]": 0.04375626806723154
1010
},
1111
"export": {
12-
"test_post_export_zip[composers-10]": 0.008332728039999467,
13-
"test_post_export_zip[composers-50]": 0.032360917022727136
12+
"test_post_export_zip[composers-10]": 0.006389603808617876,
13+
"test_post_export_zip[composers-50]": 0.02472151171218505
1414
},
1515
"search": {
16-
"test_search_full_corpus_live_scan": 0.021531250218749687,
17-
"test_search_full_corpus_indexed": 0.02971709334782733
16+
"test_search_full_corpus_indexed": 0.03357773425985082,
17+
"test_search_full_corpus_live_scan": 0.02699565326798046
1818
},
1919
"summary-cache": {
20-
"test_summary_cache_lookup[hit]": 3.6884357594611414e-05,
21-
"test_summary_cache_lookup[miss]": 3.670749401260921e-05,
22-
"test_composer_map_cache_lookup[hit]": 3.647354604953973e-05,
23-
"test_composer_map_cache_lookup[miss]": 3.59598104074222e-05,
24-
"test_fingerprint_workspace_entries[10]": 0.0017136635127184812,
25-
"test_fingerprint_workspace_entries[50]": 0.007449055283237091,
26-
"test_fingerprint_workspace_entries[200]": 0.02157815813043469,
27-
"test_summary_cache_round_trip": 0.0003182098200822204,
28-
"test_tab_summary_cache_lookup[hit]": 4.158486279113423e-05,
29-
"test_tab_summary_cache_lookup[miss]": 3.933337414450544e-05
20+
"test_composer_map_cache_lookup[hit]": 9.159433254539677e-05,
21+
"test_composer_map_cache_lookup[miss]": 9.052273017297571e-05,
22+
"test_fingerprint_workspace_entries[10]": 0.0014558767614049227,
23+
"test_fingerprint_workspace_entries[200]": 0.01772436102941095,
24+
"test_fingerprint_workspace_entries[50]": 0.006177960517756895,
25+
"test_summary_cache_lookup[hit]": 9.256659141385228e-05,
26+
"test_summary_cache_lookup[miss]": 9.249739842055407e-05,
27+
"test_summary_cache_round_trip": 0.00051773609280467,
28+
"test_tab_summary_cache_lookup[hit]": 0.00010446294267543434,
29+
"test_tab_summary_cache_lookup[miss]": 0.00010424118202523503
3030
}
3131
}
3232
}

scripts/check_benchmark_regression.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
# each round. OS page-cache state on shared runners causes 3–5x variation between
2121
# consecutive CI runs, making this ungatable with any reasonable slack.
2222
"test_summary_cache_round_trip",
23+
# Sub-100µs in-memory cache lookups vary 2.5x+ between consecutive ubuntu-latest
24+
# runs; gated ratio band (0.5x–1.2x) cannot bracket both without false failures.
25+
"test_summary_cache_lookup[hit]",
26+
"test_summary_cache_lookup[miss]",
27+
"test_composer_map_cache_lookup[hit]",
28+
"test_composer_map_cache_lookup[miss]",
29+
"test_tab_summary_cache_lookup[hit]",
30+
"test_tab_summary_cache_lookup[miss]",
2331
}
2432
)
2533

tests/test_check_benchmark_regression.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
normalize_benchmark_name,
1515
)
1616

17-
GATED_BENCH = "test_summary_cache_lookup[hit]"
17+
GATED_BENCH = "test_fingerprint_workspace_entries[10]"
1818

1919

2020
def _write_results(path, benchmarks: list[dict]) -> None:
@@ -68,12 +68,12 @@ def test_missing_baseline_warns_without_failing(
6868
results,
6969
[
7070
{"name": "test_new_bench", "stats": {"mean": 0.01}},
71-
{"name": GATED_BENCH, "stats": {"mean": 0.0001}},
71+
{"name": GATED_BENCH, "stats": {"mean": 0.001}},
7272
],
7373
)
7474
_write_baselines(
7575
baselines,
76-
{"summary-cache": {GATED_BENCH: 0.0001}},
76+
{"summary-cache": {GATED_BENCH: 0.001}},
7777
)
7878

7979
assert check_regression(results, baselines) == 0
@@ -86,11 +86,11 @@ def test_regression_over_threshold_fails(tmp_path, capsys: pytest.CaptureFixture
8686
baselines = tmp_path / "baselines.json"
8787
_write_results(
8888
results,
89-
[{"name": GATED_BENCH, "stats": {"mean": 0.00025}}],
89+
[{"name": GATED_BENCH, "stats": {"mean": 0.0025}}],
9090
)
9191
_write_baselines(
9292
baselines,
93-
{"summary-cache": {GATED_BENCH: 0.0002}},
93+
{"summary-cache": {GATED_BENCH: 0.002}},
9494
)
9595

9696
assert check_regression(results, baselines) == 1
@@ -103,11 +103,11 @@ def test_within_threshold_passes(tmp_path) -> None:
103103
baselines = tmp_path / "baselines.json"
104104
_write_results(
105105
results,
106-
[{"name": GATED_BENCH, "stats": {"mean": 0.00022}}],
106+
[{"name": GATED_BENCH, "stats": {"mean": 0.0022}}],
107107
)
108108
_write_baselines(
109109
baselines,
110-
{"summary-cache": {GATED_BENCH: 0.0002}},
110+
{"summary-cache": {GATED_BENCH: 0.002}},
111111
)
112112

113113
assert check_regression(results, baselines) == 0
@@ -137,7 +137,7 @@ def test_zero_baseline_skips_ratio_check(tmp_path, capsys: pytest.CaptureFixture
137137
baselines = tmp_path / "baselines.json"
138138
_write_results(
139139
results,
140-
[{"name": GATED_BENCH, "stats": {"mean": 0.00025}}],
140+
[{"name": GATED_BENCH, "stats": {"mean": 0.0025}}],
141141
)
142142
_write_baselines(
143143
baselines,
@@ -153,11 +153,11 @@ def test_exactly_at_threshold_passes(tmp_path) -> None:
153153
baselines = tmp_path / "baselines.json"
154154
_write_results(
155155
results,
156-
[{"name": GATED_BENCH, "stats": {"mean": 0.00024}}],
156+
[{"name": GATED_BENCH, "stats": {"mean": 0.0024}}],
157157
)
158158
_write_baselines(
159159
baselines,
160-
{"summary-cache": {GATED_BENCH: 0.0002}},
160+
{"summary-cache": {GATED_BENCH: 0.002}},
161161
)
162162

163163
assert check_regression(results, baselines) == 0
@@ -169,7 +169,7 @@ def test_missing_current_result_fails(tmp_path, capsys: pytest.CaptureFixture[st
169169
_write_results(results, [])
170170
_write_baselines(
171171
baselines,
172-
{"summary-cache": {GATED_BENCH: 0.0002}},
172+
{"summary-cache": {GATED_BENCH: 0.002}},
173173
)
174174

175175
assert check_regression(results, baselines) == 1
@@ -184,7 +184,7 @@ def test_main_reports_benchmark_data_error(tmp_path, capsys: pytest.CaptureFixtu
184184
bad = tmp_path / "bad.json"
185185
bad.write_text("{}", encoding="utf-8")
186186
baselines = tmp_path / "baselines.json"
187-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
187+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
188188

189189
assert main([str(bad), str(baselines)]) == 2
190190
assert "ERROR:" in capsys.readouterr().err
@@ -195,8 +195,8 @@ def test_duplicate_baseline_name_raises(tmp_path) -> None:
195195
_write_baselines(
196196
baselines,
197197
{
198-
"summary-cache": {GATED_BENCH: 0.0002},
199-
"export": {GATED_BENCH: 0.0003},
198+
"summary-cache": {GATED_BENCH: 0.002},
199+
"export": {GATED_BENCH: 0.003},
200200
},
201201
)
202202

@@ -220,11 +220,11 @@ def test_stale_baseline_fails(tmp_path, capsys: pytest.CaptureFixture[str]) -> N
220220
baselines = tmp_path / "baselines.json"
221221
_write_results(
222222
results,
223-
[{"name": GATED_BENCH, "stats": {"mean": 0.00005}}],
223+
[{"name": GATED_BENCH, "stats": {"mean": 0.0005}}],
224224
)
225225
_write_baselines(
226226
baselines,
227-
{"summary-cache": {GATED_BENCH: 0.0002}},
227+
{"summary-cache": {GATED_BENCH: 0.002}},
228228
)
229229

230230
assert check_regression(results, baselines) == 1
@@ -237,8 +237,8 @@ def test_main_rejects_invalid_threshold(tmp_path, capsys: pytest.CaptureFixture[
237237

238238
results = tmp_path / "results.json"
239239
baselines = tmp_path / "baselines.json"
240-
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.0001}}])
241-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
240+
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.001}}])
241+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
242242

243243
assert main([str(results), str(baselines), "--threshold", "1.0"]) == 2
244244
assert "threshold must be greater than 1" in capsys.readouterr().err
@@ -249,8 +249,8 @@ def test_main_rejects_invalid_stale_floor(tmp_path, capsys: pytest.CaptureFixtur
249249

250250
results = tmp_path / "results.json"
251251
baselines = tmp_path / "baselines.json"
252-
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.0001}}])
253-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
252+
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.001}}])
253+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
254254

255255
assert main([str(results), str(baselines), "--stale-floor", "1.5"]) == 2
256256
assert "stale_floor must be between 0 and 1" in capsys.readouterr().err
@@ -259,8 +259,8 @@ def test_main_rejects_invalid_stale_floor(tmp_path, capsys: pytest.CaptureFixtur
259259
def test_check_regression_rejects_invalid_threshold(tmp_path) -> None:
260260
results = tmp_path / "results.json"
261261
baselines = tmp_path / "baselines.json"
262-
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.0001}}])
263-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
262+
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.001}}])
263+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
264264

265265
with pytest.raises(BenchmarkDataError, match="threshold must be greater than 1"):
266266
check_regression(results, baselines, threshold=1.0)
@@ -269,8 +269,8 @@ def test_check_regression_rejects_invalid_threshold(tmp_path) -> None:
269269
def test_check_regression_rejects_non_finite_threshold(tmp_path) -> None:
270270
results = tmp_path / "results.json"
271271
baselines = tmp_path / "baselines.json"
272-
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.0001}}])
273-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
272+
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.001}}])
273+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
274274

275275
with pytest.raises(BenchmarkDataError, match="threshold must be finite"):
276276
check_regression(results, baselines, threshold=float("nan"))
@@ -281,8 +281,8 @@ def test_main_rejects_non_finite_threshold(tmp_path, capsys: pytest.CaptureFixtu
281281

282282
results = tmp_path / "results.json"
283283
baselines = tmp_path / "baselines.json"
284-
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.0001}}])
285-
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.0002}})
284+
_write_results(results, [{"name": GATED_BENCH, "stats": {"mean": 0.001}}])
285+
_write_baselines(baselines, {"summary-cache": {GATED_BENCH: 0.002}})
286286

287287
assert main([str(results), str(baselines), "--threshold", "inf"]) == 2
288288
assert "threshold must be finite" in capsys.readouterr().err

0 commit comments

Comments
 (0)