Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ci/llgo-size/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions ci/llgo-size/enrich_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the newest-first result depends on main_history being passed oldest-first (enumerated 1=oldest → N=newest, then sorted reverse=True). That invariant is only documented in the argparse help. A one-line comment here noting main_history is expected oldest-first would keep the intent local to where it's consumed.

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):
Expand Down
6 changes: 3 additions & 3 deletions ci/llgo-size/site/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the variable is named newest, but it's returned reversed to oldest-first on the next line. A name like recent or selected would read less contradictorily, since the returned array is chronological (oldest→newest), not newest-first. Behavior is correct.

return newest.reverse();
}

function chartBand(documents, metas, benchmarkName, measure, title) {
Expand Down Expand Up @@ -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())]);
Expand Down
4 changes: 2 additions & 2 deletions ci/llgo-size/test_enrich_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading