Chart each measured merge on elfuse-bench

XA
1d ago
+421-3

Intent: Add each measured merge to main to the elfuse-bench dashboard (https://sysprog21.github.io/elfuse-bench/): per metric, the median of the head rounds, and the median of the base rounds as a second series, so a shift of the runner shows as both series moving at the same merge. This is PR 4 of #503.

This PR:

  • scripts/bench-dashboard.py turns the bench-rounds artifact into the customSmallerIsBetter input of benchmark-action/github-action-benchmark. For each Tier 1 and Tier 2 metric it gives the median of the head-N.json rounds under the metric's name in the comparison report, and the median of the base-N.json rounds under that name with (base) appended; for each Tier 3 metric, its median in head-oci.json; a head-oci.json it cannot use, such as one a timeout cut short, gives no Tier 3 point and leaves the rest. As in bench-compare.py, an ERR row, a zero and a tier the round records as skipped count as missing, and a metric missing from every round of a side gets no point on that side. A side's median takes every round of that side with a value, where the comparison keeps only the rounds in which both sides have one. Of the round files it reads only base-N.json and head-N.json, so the confirm-* rounds of #543 do not change the points. Given the dashboard's data.js and a commit, it leaves out the metrics data.js already holds for that commit; a metric with only one of its two points there gets both again, so the head and base points of a merge come from one run. Its self-test runs in make check-bench-report.
  • benchmark.yml adds a publish job for push runs only, so the label and schedule runs of #543 never reach the chart. It adds no point when report.json is missing (the comparison did not complete), and still adds Tier 1 and Tier 2 when Tier 3 failed. A failed download of the rounds fails the job, so "Re-run failed jobs" can retry it. The action appends an entry even for a commit it already holds, so the job first fetches data.js (10 s to connect, 60 s in all) and publishes only the points it lacks: "Re-run failed jobs" after a failed Tier 3 adds just the Tier 3 points. A fetch that fails, or returns a copy raw.githubusercontent.com cached before the earlier attempt pushed (it keeps one for up to 5 minutes, and that attempt's own fetch can fill it), publishes the points a second time. The action is pinned to commit 4322e57 (v1.22.2), and the step that runs it is the only one that gets the token. There is no concurrency group: when two publishes race, the one whose push is rejected clones again and retries inside the action.

The script is Python, as #503 now says, because its self-test runs in make check, the bench scripts already need python3, and the host requirements in docs/testing.md do not list jq. The separate lat_syscall null series that #503 asks for needs no code, because the dashboard draws one chart per metric.

#543 edits the same workflow. This PR only appends a job and a header line there, and git merge-tree with #543's branch reports no conflict.

Setup: elfuse-bench now has a main branch served by GitHub Pages, with an empty data.js and an index.html that draws each X (base) series on the chart of X, one point per commit, with commits in order of their commit time. What is left needs an elfuse admin: the repository secret ELFUSE_BENCH_TOKEN, a fine-grained token with Contents read and write on sysprog21/elfuse-bench only. Until it is set, the job prints a notice and passes, so no merge goes red.

Testing:

  • make check-bench-report passes under Python 3.14 and 3.9 at each commit; make check-format and scripts/check-commit-log.sh pass. make check passes except the test-busybox nslookup case, which fails the same way on an upstream/main build.
  • Each self-test case fails when the code it covers is broken. 19 mutations were each caught: a match on the round file names without the start or the end anchor, mean instead of median, dropping a metric that only base measured, accepting an empty list, no unit check, no base-round check, no meta.env check, no rounding, keeping a zero, ignoring a skipped tier, no data.js filter, filtering point by point instead of by metric, matching another commit's entry, failing on an unreadable data.js, failing on an unusable head-oci.json, catching only one of its two kinds of error (two mutations), and publishing its Tier 3 points anyway.
  • On the bench-rounds artifact of run 44836576102, the script gives 34 points (15 metrics with head and base, and 4 Tier 3). Each Tier 1 and Tier 2 value equals the median of that side's list in report.json; the script rounds to 12 significant digits, which drops only float noise such as 1.0261999999999998.
  • The points step of the publish job, taken from the YAML and run locally on that artifact: with no report.json it prints the notice and publishes nothing; with every point already in data.js, and on a rerun whose Tier 3 failed again with Tier 1 and 2 already there, the other notice and nothing published; with Tier 1 and 2 already there, the 4 Tier 3 points; with one side of a metric already there, both of its points; with the commit absent from the live data.js, 34 points; on a 404, and on a server that accepts and never answers (time limit lowered to 3 s), the warning and 34 points.

Not tested: The publish job has not run on GitHub Actions, because it runs only on a push to main; the notice while the secret is unset is checked by reading. actionlint was not run. The dashboard page has not been opened in a browser; its script was run with a stub DOM on made-up data.

Refs #503