From 825f1d6722d167c305f0544bd931ee65c65fd679 Mon Sep 17 00:00:00 2001 From: ZhouGuangyuan Date: Sat, 22 Aug 2026 12:23:25 +0800 Subject: [PATCH] ci: show newest binary-size revisions first --- ci/llgo-size/README.md | 5 +++-- ci/llgo-size/enrich_pull_requests.py | 22 +++++++++++++++------- ci/llgo-size/site/app.js | 6 +++--- ci/llgo-size/test_enrich_pull_requests.py | 4 ++-- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ci/llgo-size/README.md b/ci/llgo-size/README.md index 69cebaf..6d27e23 100644 --- a/ci/llgo-size/README.md +++ b/ci/llgo-size/README.md @@ -85,8 +85,9 @@ The benchmark and page-only workflows use separate concurrency keys. Pages publication retries from the latest `pages` tip if parallel benchmark runs finish together. The index records each result's position on LLGo's first-parent `main` history and displays commits in that order rather than build completion -order; the dashboard opens on the newest page while keeping its columns oldest -to newest. +order; the dashboard keeps the newest commits on the first page and orders its +columns newest to oldest. Trend charts reverse that selection for chronological +left-to-right display. Pull requests that change the committed LLGo version, Bent, the LLGo-size benchmark/configuration files, or the suite definitions used by those cases diff --git a/ci/llgo-size/enrich_pull_requests.py b/ci/llgo-size/enrich_pull_requests.py index ac973f4..c2ca696 100644 --- a/ci/llgo-size/enrich_pull_requests.py +++ b/ci/llgo-size/enrich_pull_requests.py @@ -128,14 +128,22 @@ def order_runs(index, main_history): if commit in positions: run["llgoMainIndex"] = positions[commit] - def order_key(run): + runs = index.setdefault("runs", []) + def is_main_run(run): position = run.get("llgoMainIndex") - if isinstance(position, int) and not isinstance(position, bool): - return (0, position, "", str(run.get("key", ""))) - committed_at = str(run.get("llgoCommittedAt") or run.get("createdAt") or "") - return (1, 0, committed_at, str(run.get("key", ""))) - - index.setdefault("runs", []).sort(key=order_key) + return isinstance(position, int) and not isinstance(position, bool) + + main_runs = [run for run in runs if is_main_run(run)] + other_runs = [run for run in runs if not is_main_run(run)] + main_runs.sort(key=lambda run: run["llgoMainIndex"], reverse=True) + other_runs.sort( + key=lambda run: ( + str(run.get("llgoCommittedAt") or run.get("createdAt") or ""), + str(run.get("key", "")), + ), + reverse=True, + ) + runs[:] = main_runs + other_runs def legacy_wall_times(run, document, data_dir): diff --git a/ci/llgo-size/site/app.js b/ci/llgo-size/site/app.js index 87890ea..9410d86 100644 --- a/ci/llgo-size/site/app.js +++ b/ci/llgo-size/site/app.js @@ -257,7 +257,7 @@ function findMeta(key) { function latestRun() { const runs = state.index && state.index.runs || []; - return runs[runs.length - 1]; + return runs[0]; } function measureValue(benchmark, config, measure) { @@ -469,7 +469,8 @@ async function renderTables() { function chartRuns() { const limit = Number(dom.historyRange.value); - return limit > 0 ? state.index.runs.slice(-limit) : state.index.runs.slice(); + const newest = limit > 0 ? state.index.runs.slice(0, limit) : state.index.runs.slice(); + return newest.reverse(); } function chartBand(documents, metas, benchmarkName, measure, title) { @@ -640,7 +641,6 @@ async function main() { if (!response.ok) throw new Error("Cannot load the run index"); state.index = await response.json(); if (!state.index.runs || !state.index.runs.length) throw new Error("No benchmark runs are available"); - state.page = Math.max(1, Math.ceil(state.index.runs.length / state.pageSize)); state.benchmarkNames = sortedBenchmarkNames(state.index.benchmarkNames); if (!state.benchmarkNames.length) { state.benchmarkNames = benchmarkNamesFromDocuments([await loadRun(latestRun())]); diff --git a/ci/llgo-size/test_enrich_pull_requests.py b/ci/llgo-size/test_enrich_pull_requests.py index f4eef28..d92be80 100644 --- a/ci/llgo-size/test_enrich_pull_requests.py +++ b/ci/llgo-size/test_enrich_pull_requests.py @@ -99,8 +99,8 @@ def test_orders_runs_by_llgo_main_history_instead_of_build_completion(self): MODULE.order_runs(index, [first, second]) - self.assertEqual([run["key"] for run in index["runs"]], [first, second]) - self.assertEqual([run["llgoMainIndex"] for run in index["runs"]], [1, 2]) + self.assertEqual([run["key"] for run in index["runs"]], [second, first]) + self.assertEqual([run["llgoMainIndex"] for run in index["runs"]], [2, 1]) def test_places_non_main_runs_after_topological_history(self): main = "a" * 40