Skip to content

Commit f459685

Browse files
hunhoffeclaude
andcommitted
Prune each benchmark's weeks on its own runs
prune() took the newest run of each ISO week across the whole suite, so a benchmark that ran that week, but not in its last run, lost the week: with A on June 1 and 8 and B on June 7 and 14, A kept neither. Each benched parametrization now keeps its own newest run of each week, and its own MAX_RUNS; the 90-day window is still measured from the suite's newest run, and every other row still keeps the suite's last two. On the ci branch today that is 64 MB down to 8.3 MB, measured on the files directly; the 13 MB 1d2f0a3 gave counted the latest run twice. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3623205 commit f459685

2 files changed

Lines changed: 37 additions & 18 deletions

File tree

‎ci/scripts/merge_all.py‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
def prune(rows, date_fmt="%Y-%m-%d %H:%M:%S"):
1919
"""Keep the runs the reports and the Benchmarks page read.
2020
21-
A run is the rows of one date. A benched parametrization keeps every run of
22-
the last `KEEP_DAYS` before the newest, the newest run of each ISO week
23-
before that, and at most `MAX_RUNS` runs. The trends compare a run with
24-
the one before it, so every other row keeps the last two runs. Measured
25-
from the newest run, a skewed clock on one runner cannot empty the file.
21+
A run is the rows of one date. Each benched parametrization keeps its own
22+
runs of the last `KEEP_DAYS` before the suite's newest, its newest run of
23+
each ISO week before that, and at most `MAX_RUNS` runs: a week another
24+
test ran later in keeps this one's run too. The trends compare a run with
25+
the one before it, so every other row keeps the suite's last two runs.
26+
Measured from the newest run, a skewed clock on one runner cannot empty
27+
the file.
2628
"""
2729
dated = []
2830
for row in rows:
@@ -33,22 +35,27 @@ def prune(rows, date_fmt="%Y-%m-%d %H:%M:%S"):
3335
runs = sorted({date for date, _ in dated})
3436
if not runs:
3537
return []
36-
3738
cutoff = runs[-1] - timedelta(days=KEEP_DAYS)
38-
weekly = {}
39-
for date in runs:
40-
if date < cutoff:
41-
weekly[date.isocalendar()[:2]] = date
42-
kept = set(
43-
sorted({d for d in runs if d >= cutoff} | set(weekly.values()))[-MAX_RUNS:]
44-
)
4539
last_two = set(runs[-2:])
4640

4741
benched = {row_key(row) for row in select_bench_rows(rows)}
42+
runs_of = {}
43+
for date, row in dated:
44+
if row_key(row) in benched:
45+
runs_of.setdefault(row_key(row), set()).add(date)
46+
kept = {}
47+
for key, dates in runs_of.items():
48+
weekly = {}
49+
for date in sorted(dates):
50+
if date < cutoff:
51+
weekly[date.isocalendar()[:2]] = date
52+
recent = {date for date in dates if date >= cutoff}
53+
kept[key] = set(sorted(recent | set(weekly.values()))[-MAX_RUNS:])
54+
4855
return [
4956
row
5057
for date, row in dated
51-
if date in last_two or (date in kept and row_key(row) in benched)
58+
if date in last_two or date in kept.get(row_key(row), ())
5259
]
5360

5461

‎iron/tests/infrastructure/test_merge_results.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"""The results branch's retention, run as publish-results.yml runs it.
55
66
``merge_results.sh`` keeps a benched test's runs of the last 90 days, the
7-
newest of each ISO week before that, at most 400; and every other test's last
8-
two runs, all the trends read of it.
7+
newest of each ISO week it ran in before that, at most 400; and every other
8+
test's last two runs, all the trends read of it.
99
"""
1010

1111
import csv
@@ -18,9 +18,10 @@
1818
COLUMNS = ["Commit", "Date", "Test Path", "Test", "Checks", "Bench", "Latency (mean)"]
1919
BENCHED = ("iron/tests/operators/test_catalog.py::test_operator", "npu2-GEMV-M_2048")
2020
PLAIN = ("iron/tests/common/test_graph.py::test_record", "test_record")
21+
OTHER = ("iron/tests/operators/test_catalog.py::test_operator", "npu2-GEMV-M_4096")
2122

2223

23-
def _rows(dates):
24+
def _rows(dates, tests=((BENCHED, "yes"), (PLAIN, "no"))):
2425
return [
2526
{
2627
"Commit": "abc1234",
@@ -32,7 +33,7 @@ def _rows(dates):
3233
"Latency (mean)": "1.0",
3334
}
3435
for date in dates
35-
for (path, test), bench in ((BENCHED, "yes"), (PLAIN, "no"))
36+
for (path, test), bench in tests
3637
]
3738

3839

@@ -74,3 +75,14 @@ def test_a_benched_test_keeps_at_most_400_runs(tmp_path):
7475
hours = [newest - timedelta(hours=n) for n in range(1, 500)]
7576
kept = _merge(tmp_path, _rows(hours), _rows([newest]))
7677
assert kept[BENCHED[1]] == {newest} | set(hours[:399])
78+
79+
80+
def test_each_benchmark_keeps_its_own_newest_run_of_a_week(tmp_path):
81+
"""A week another benchmark ran later in keeps this one's run too."""
82+
a, b = ((BENCHED, "yes"),), ((OTHER, "yes"),)
83+
june = [datetime(2026, 6, d, 10) for d in (1, 7, 8, 14)]
84+
newest = datetime(2026, 10, 30, 10)
85+
history = _rows([june[0], june[2]], a) + _rows([june[1], june[3]], b)
86+
kept = _merge(tmp_path, history, _rows([newest], a + b))
87+
assert kept[BENCHED[1]] == {june[0], june[2], newest}
88+
assert kept[OTHER[1]] == {june[1], june[3], newest}

0 commit comments

Comments
 (0)