From 2708f10152acda8f8ef25e6bf6510a0e42fed313 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Thu, 26 Nov 2026 21:43:09 +0100 Subject: [PATCH 1/6] Add CodSpeed walltime benchmarks workflow Builds a release native standalone on the CI pool, checks it on a hosted runner, and measures the C API micro benchmarks and the pure Python meso benchmarks on the self-hosted benchmark runner linux-amd64-bench. Results go to CodSpeed and are kept as a workflow artifact. Runs on pushes to master and elide-*.x, and on pull requests labelled perf:bench. --- .github/scripts/codspeed_bench.py | 267 ++++++++++++++++++++++++++++++ .github/workflows/codspeed.yml | 152 +++++++++++++++++ 2 files changed, 419 insertions(+) create mode 100644 .github/scripts/codspeed_bench.py create mode 100644 .github/workflows/codspeed.yml diff --git a/.github/scripts/codspeed_bench.py b/.github/scripts/codspeed_bench.py new file mode 100644 index 0000000000..deedb96524 --- /dev/null +++ b/.github/scripts/codspeed_bench.py @@ -0,0 +1,267 @@ +# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# The Universal Permissive License (UPL), Version 1.0 +# +# Subject to the condition set forth below, permission is hereby granted to any +# person obtaining a copy of this software, associated documentation and/or +# data (collectively the "Software"), free of charge and under any and all +# copyright rights in the Software, and any and all patent rights owned or +# freely licensable by each licensor hereunder covering either (i) the +# unmodified Software as contributed to or provided by such licensor, or (ii) +# the Larger Works (as defined below), to deal in both +# +# (a) the Software, and +# +# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if +# one is included with the Software each a "Larger Work" to which the Software +# is contributed by such licensors), +# +# without restriction, including without limitation the rights to copy, create +# derivative works of, display, perform, and distribute the Software and make, +# use, sell, offer for sale, import, export, have made, and have sold the +# Software and the Larger Work(s), and to sublicense the foregoing rights on +# either these or other terms. +# +# This license is subject to the following condition: +# +# The above copyright notice and either this complete permission notice or at a +# minimum a reference to the UPL must be included in all copies or substantial +# portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# ================================ +# +# Runs benchmarks from graalpython/com.oracle.graal.python.benchmarks with the upstream harness and +# reports steady-state wall time to CodSpeed. Used by .github/workflows/codspeed.yml; runs on CPython. +# +# Every benchmark runs in its own process of the interpreter under test. The harness prints one +# duration per iteration; the first half of the iterations is warm-up and the second half are the +# samples. One CodSpeed walltime result file is written per benchmark to +# $CODSPEED_PROFILE_FOLDER/results. Without that variable (a local run) nothing is reported. --output +# keeps a copy of all statistics in one file, whether or not CodSpeed takes them. + +#!/usr/bin/env python3 +import argparse +import importlib.util +import json +import math +import os +import re +import statistics +import subprocess +import sys +import time +import types + +REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +BENCH_REL = "graalpython/com.oracle.graal.python.benchmarks/python" +HARNESS = os.path.join(REPO, BENCH_REL, "harness.py") +PARAMS = os.path.join(REPO, "mx.graalpython", "mx_graalpython_bench_param.py") + +# suite name -> (table in mx_graalpython_bench_param.py, directory under BENCH_REL) +SUITES = { + "micro-native": ("MICRO_NATIVE_BENCHMARKS", "micro"), + "meso": ("MESO_BENCHMARKS", "meso"), + "micro": ("MICRO_BENCHMARKS", "micro"), +} +DEFAULT_SUITES = ["micro-native", "meso"] + +# The second half of the iterations are the samples, so this gives at least four. +MIN_ITERATIONS = 8 + +# Not measured. Any other benchmark that fails makes the run fail. +SKIP = { + # About 150 s per iteration on a native standalone (measured on an Apple M1 Pro). + "meso/chaos-traced": "minutes per iteration", +} + +CREATOR = {"name": "graalpy-harness", "version": "1.0.0"} + + +def load_table(name): + """Reads a benchmark table from the mx benchmark definitions without mx.""" + saved = sys.modules.get("mx") + stub = types.ModuleType("mx") + stub.suite = lambda _name: types.SimpleNamespace(dir=REPO) + sys.modules["mx"] = stub + try: + spec = importlib.util.spec_from_file_location("_graalpy_bench_param", PARAMS) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + finally: + if saved is None: + del sys.modules["mx"] + else: + sys.modules["mx"] = saved + return getattr(module, name) + + +def split_args(harness_args): + """-> (iterations, other harness options, workload arguments)""" + iterations, options, workload = 1, [], [] + i = 0 + while i < len(harness_args): + arg = harness_args[i] + if arg == "-i": + iterations = int(harness_args[i + 1]) + i += 2 + elif arg in ("-w", "-r", "-p"): + options += harness_args[i:i + 2] + i += 2 + elif arg.startswith("--"): + options.append(arg) + i += 1 + else: + workload.append(arg) + i += 1 + return iterations, options, workload + + +def benchmarks(suites, pattern): + for suite in suites: + table, directory = SUITES[suite] + for name, harness_args in load_table(table).items(): + ident = "%s/%s" % (suite, name) + if pattern and not re.search(pattern, ident): + continue + iterations, options, workload = split_args(list(harness_args)) + rel = "%s/%s/%s.py" % (BENCH_REL, directory, name) + # The identity CodSpeed keeps the history under. The workload size is part of it, the + # iteration count is not. + uri = "%s::%s%s" % (rel, ident, "[%s]" % ",".join(workload) if workload else "") + yield {"id": ident, "uri": uri, "file": os.path.join(REPO, rel), "iterations": iterations, + "options": options, "workload": workload} + + +def quantile(values, p): + position = p * (len(values) - 1) + low = int(position) + high = min(low + 1, len(values) - 1) + return values[low] + (position - low) * (values[high] - values[low]) + + +def walltime_stats(durations_s): + """CodSpeed walltime statistics. A round is one harness iteration after warm-up.""" + warmup = len(durations_s) // 2 + samples = sorted(d * 1e9 for d in durations_s[warmup:]) + mean = statistics.fmean(samples) + stdev = statistics.stdev(samples) + q1, q3 = quantile(samples, .25), quantile(samples, .75) + iqr = q3 - q1 + return { + "min_ns": samples[0], "max_ns": samples[-1], "mean_ns": mean, "stdev_ns": stdev, + "q1_ns": q1, "median_ns": quantile(samples, .5), "q3_ns": q3, + "rounds": len(samples), "total_time": sum(durations_s), + "iqr_outlier_rounds": sum(1 for s in samples if s < q1 - 1.5 * iqr or s > q3 + 1.5 * iqr), + "stdev_outlier_rounds": sum(1 for s in samples if abs(s - mean) > 2 * stdev), + "iter_per_round": 1, "warmup_iters": warmup, + } + + +def run_one(python, bench, min_iterations, timeout): + """-> (status, durations in seconds, pid, output tail)""" + iterations = max(bench["iterations"], min_iterations) + cmd = [python, HARNESS, bench["file"], "-i", str(iterations)] + bench["options"] + bench["workload"] + # With CI set the harness stops early once long iterations look stable; every iteration is wanted here. + env = {k: v for k, v in os.environ.items() if k != "CI"} + proc = subprocess.Popen(cmd, cwd=os.path.dirname(bench["file"]), env=env, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, text=True, errors="replace") + try: + out, _ = proc.communicate(timeout=timeout) + except subprocess.TimeoutExpired: + proc.kill() + out, _ = proc.communicate() + return "timeout after %ds" % timeout, [], proc.pid, out[-3000:] + if proc.returncode != 0: + return "exit %d" % proc.returncode, [], proc.pid, out[-3000:] + # Full precision; the per-iteration lines are rounded to a millisecond. + match = re.search(r"^### RAW DURATIONS: \[([^\]]*)\]", out, re.M) + durations = [float(x) for x in match.group(1).split(",")] if match and match.group(1).strip() else [] + if len(durations) != iterations: + return "%d of %d iterations reported" % (len(durations), iterations), [], proc.pid, out[-3000:] + if any(not math.isfinite(d) or d <= 0 for d in durations): + return "non-positive duration", [], proc.pid, out[-3000:] + return "ok", durations, proc.pid, "" + + +def write_result(folder, bench, stats, pid): + results = os.path.join(folder, "results") + os.makedirs(results, exist_ok=True) + report = { + "creator": dict(CREATOR, pid=pid), + "instrument": {"type": "walltime"}, + "benchmarks": [{ + "name": bench["uri"].split("::", 1)[1], "uri": bench["uri"], + "config": {"warmup_time_ns": None, "min_round_time_ns": None, "max_time_ns": None, "max_rounds": None}, + "stats": stats, + }], + } + with open(os.path.join(results, "%d.json" % pid), "w") as f: + json.dump(report, f) + + +def main(): + parser = argparse.ArgumentParser(description="Report GraalPy harness benchmarks to CodSpeed (walltime).") + parser.add_argument("--python", required=True, help="interpreter to measure") + parser.add_argument("--suite", nargs="+", choices=sorted(SUITES), default=DEFAULT_SUITES) + parser.add_argument("--bench", help="regular expression matched against suite/name") + parser.add_argument("--min-iterations", type=int, default=MIN_ITERATIONS) + parser.add_argument("--timeout", type=int, default=900, help="seconds per benchmark process") + parser.add_argument("--output", help="directory for walltime-summary.json") + parser.add_argument("--list", action="store_true", help="print the benchmarks and exit") + args = parser.parse_args() + if args.min_iterations < 4: + parser.error("--min-iterations must be at least 4: two samples are the minimum") + + if os.path.exists(args.python): + # Each benchmark runs in its own directory. + args.python = os.path.abspath(args.python) + selected = list(benchmarks(args.suite, args.bench)) + if not selected: + parser.error("no benchmark selected") + if args.list: + for bench in selected: + print(bench["uri"], "(skipped: %s)" % SKIP[bench["id"]] if bench["id"] in SKIP else "") + return 0 + + folder = os.environ.get("CODSPEED_PROFILE_FOLDER") + if not folder: + print("CODSPEED_PROFILE_FOLDER is not set: nothing is reported to CodSpeed", flush=True) + failed, measured, summary = [], 0, {} + print("%-48s %10s %10s %7s %s" % ("benchmark", "median s", "stdev s", "rounds", "status"), flush=True) + for bench in selected: + if bench["id"] in SKIP: + print("%-48s %10s %10s %7s skipped: %s" % (bench["id"], "-", "-", "-", SKIP[bench["id"]]), flush=True) + continue + started = time.monotonic() + status, durations, pid, tail = run_one(args.python, bench, args.min_iterations, args.timeout) + if status != "ok": + failed.append(bench["id"]) + print("%-48s %10s %10s %7s FAILED: %s" % (bench["id"], "-", "-", "-", status), flush=True) + print(tail, flush=True) + continue + stats = walltime_stats(durations) + if folder: + write_result(folder, bench, stats, pid) + summary[bench["uri"]] = stats + measured += 1 + print("%-48s %10.4f %10.4f %7d ok (%ds)" % (bench["id"], stats["median_ns"] / 1e9, stats["stdev_ns"] / 1e9, + stats["rounds"], time.monotonic() - started), flush=True) + if args.output: + os.makedirs(args.output, exist_ok=True) + with open(os.path.join(args.output, "walltime-summary.json"), "w") as f: + json.dump({"measured": summary, "failed": failed}, f, indent=1) + print("%d measured, %d failed%s" % (measured, len(failed), ": " + ", ".join(failed) if failed else "")) + return 1 if failed or not measured else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 0000000000..ac9b14515d --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,152 @@ +name: CodSpeed benchmarks +# Steady-state wall time of the C API micro benchmarks and the pure Python meso benchmarks on a +# native standalone, reported to CodSpeed (https://app.codspeed.io/elide-dev/graalpython). +# +# Wall time needs a dedicated machine, so the measurement runs on the self-hosted benchmark runner +# linux-amd64-bench. The repository variable +# CODSPEED_WALLTIME_RUNNER selects another label; the standalone is built for linux-amd64, so it +# must be an x86_64 runner. The benchmark host is shared between repositories, so the standalone is +# built on the CI pool and the host is used only for the measurement. +# +# Pull requests are measured only when labelled "perf:bench", and never from a fork: both the build +# and the measurement run on self-hosted runners. +on: + push: + branches: [master, 'elide-*.x'] + pull_request: + types: [opened, synchronize, reopened, labeled] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: codspeed-${{ github.ref }} + # Every commit on a release branch is measured; a superseded pull request run is not. + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + # A release build. The standalone of the unittest workflow has assertions enabled and is built in + # quick mode (-Ob), so it cannot be measured. + build: + name: build native standalone + if: >- + github.event_name != 'pull_request' || + (contains(github.event.pull_request.labels.*.name, 'perf:bench') && + github.event.pull_request.head.repo.full_name == github.repository) + runs-on: ${{ vars.CODSPEED_BUILD_RUNNER || 'linux-amd64-cipool' }} + timeout-minutes: 120 + steps: + # The self-hosted runners keep their workspace between jobs, and mx and the graal + # repository are cloned next to the checkout, so start from an empty workspace. + - name: Clean workspace + run: find "${GITHUB_WORKSPACE:?}" -mindepth 1 -maxdepth 1 -exec rm -rf {} + + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: main + + - name: Get mx and labsjdk + run: | + git config --global http.timeout 600 + git clone https://github.com/graalvm/mx + ./mx/mx fetch-jdk -A --configuration main/ci/graal/common.json --jdk-id labsjdk-ce-latest + git -C mx checkout "$(python3 -c 'import json; print(json.load(open("main/ci/graal/common.json"))["mx_version"])')" + echo "$(pwd)/mx/" >> "$GITHUB_PATH" + echo "JAVA_HOME=$HOME/.mx/jdks/labsjdk-ce-latest" >> "$GITHUB_ENV" + echo "JVMCI_VERSION_CHECK=ignore" >> "$GITHUB_ENV" + + - name: Build + working-directory: main + # GITHUB_CI and BUILD_WITH_ASSERTIONS stay unset: they select the quick build mode and assertions. + run: | + mx sforceimports + mx sversions + mx python-svm + + # A tar keeps the executable bits and symbolic links that artifacts drop. + - name: Pack the standalone + run: tar -C main/mxbuild/linux-amd64 -cf "$RUNNER_TEMP/graalpy-native-standalone.tar" GRAALPY_NATIVE_STANDALONE + + - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 + with: + name: codspeed-graalpy-native-standalone + path: ${{ runner.temp }}/graalpy-native-standalone.tar + retention-days: 1 + if-no-files-found: error + + # The standalone was built on another machine, and the C API benchmarks compile an extension when + # they start. Check both on a hosted runner before the benchmark host is occupied. No timing is + # taken from this job. + check: + name: check standalone + needs: build + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: codspeed-graalpy-native-standalone + path: ${{ runner.temp }} + + - name: Run three C API benchmarks + run: | + tar -C "$RUNNER_TEMP" -xf "$RUNNER_TEMP/graalpy-native-standalone.tar" + GRAALPY="$RUNNER_TEMP/GRAALPY_NATIVE_STANDALONE/bin/graalpy" + "$GRAALPY" -c 'import sys; print(sys.version)' + # The last two call C API functions that the public headers do not declare. + python3 .github/scripts/codspeed_bench.py --python "$GRAALPY" \ + --bench '^micro-native/(c-instantiate-large|c-to-c|c-call-method-obj-args)$' + + walltime: + name: walltime + needs: [build, check] + runs-on: ${{ vars.CODSPEED_WALLTIME_RUNNER || 'linux-amd64-bench' }} + timeout-minutes: 90 + permissions: + contents: read + id-token: write # CodSpeed OIDC + env: + BENCH_OUTPUT: ${{ github.workspace }}/codspeed-results + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: codspeed-graalpy-native-standalone + path: ${{ runner.temp }} + + - name: Unpack the standalone + run: | + uname -a; cat /etc/os-release; nproc + tar -C "$RUNNER_TEMP" -xf "$RUNNER_TEMP/graalpy-native-standalone.tar" + cc --version + "$RUNNER_TEMP/GRAALPY_NATIVE_STANDALONE/bin/graalpy" -c 'import sys; print(sys.version)' + + - name: Measure + # Action and runner versions already in use on this host. + uses: CodSpeedHQ/action@b1f28b5eccf7cb5bfe6a2a89cb3053eb67f1150c # v5.8.0 + env: + # The driver reports its own results and calls no CodSpeed instrumentation hooks, so the + # runner's sampling profiler has no benchmark to attach its samples to. + CODSPEED_PROFILER_ENABLED: 'false' + with: + mode: walltime + runner-version: "5.2.1" + run: >- + python3 .github/scripts/codspeed_bench.py + --python "${{ runner.temp }}/GRAALPY_NATIVE_STANDALONE/bin/graalpy" + --suite micro-native meso + --output "${{ env.BENCH_OUTPUT }}" + + # Independent of the upload to CodSpeed. + - name: Keep the measurements + if: ${{ !cancelled() }} + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 + with: + name: codspeed-walltime-${{ github.run_attempt }} + path: ${{ env.BENCH_OUTPUT }}/*.json + retention-days: 14 + if-no-files-found: warn From f7b524673d7f3d4ff6aa4fde34359e64fa1cd9b3 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Thu, 26 Nov 2026 21:43:09 +0100 Subject: [PATCH 2/6] Compile the C API benchmarks with newer compilers and report partial runs Two benchmarks call functions that the public headers do not declare, which GCC 14 and later reject by default. A failed benchmark no longer discards the other results: they are uploaded and the job fails afterwards. --- .github/scripts/codspeed_bench.py | 12 +++++++++++- .github/workflows/codspeed.yml | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/scripts/codspeed_bench.py b/.github/scripts/codspeed_bench.py index deedb96524..48cedacc0f 100644 --- a/.github/scripts/codspeed_bench.py +++ b/.github/scripts/codspeed_bench.py @@ -172,6 +172,9 @@ def run_one(python, bench, min_iterations, timeout): cmd = [python, HARNESS, bench["file"], "-i", str(iterations)] + bench["options"] + bench["workload"] # With CI set the harness stops early once long iterations look stable; every iteration is wanted here. env = {k: v for k, v in os.environ.items() if k != "CI"} + # Some C API benchmarks call functions that the public headers do not declare. GCC 14 and + # clang 16 made that an error; it was a warning when the benchmarks were written. + env["CFLAGS"] = (env.get("CFLAGS", "") + " -Wno-error=implicit-function-declaration").strip() proc = subprocess.Popen(cmd, cwd=os.path.dirname(bench["file"]), env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, errors="replace") try: @@ -216,8 +219,13 @@ def main(): parser.add_argument("--min-iterations", type=int, default=MIN_ITERATIONS) parser.add_argument("--timeout", type=int, default=900, help="seconds per benchmark process") parser.add_argument("--output", help="directory for walltime-summary.json") + parser.add_argument("--defer-failures", action="store_true", + help="exit 0 when a benchmark fails, so that the others are still reported; " + "the failures are in walltime-summary.json") parser.add_argument("--list", action="store_true", help="print the benchmarks and exit") args = parser.parse_args() + if args.defer_failures and not args.output: + parser.error("--defer-failures needs --output") if args.min_iterations < 4: parser.error("--min-iterations must be at least 4: two samples are the minimum") @@ -260,7 +268,9 @@ def main(): with open(os.path.join(args.output, "walltime-summary.json"), "w") as f: json.dump({"measured": summary, "failed": failed}, f, indent=1) print("%d measured, %d failed%s" % (measured, len(failed), ": " + ", ".join(failed) if failed else "")) - return 1 if failed or not measured else 0 + if not measured: + return 1 + return 1 if failed and not args.defer_failures else 0 if __name__ == "__main__": diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index ac9b14515d..83b0c59b3b 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -140,6 +140,17 @@ jobs: --python "${{ runner.temp }}/GRAALPY_NATIVE_STANDALONE/bin/graalpy" --suite micro-native meso --output "${{ env.BENCH_OUTPUT }}" + --defer-failures + + # A failed benchmark does not stop the others from being reported, but it fails the job. + - name: Fail on failed benchmarks + run: | + python3 - "$BENCH_OUTPUT/walltime-summary.json" <<'EOF' + import json, sys + failed = json.load(open(sys.argv[1]))["failed"] + if failed: + sys.exit("failed benchmarks: " + ", ".join(failed)) + EOF # Independent of the upload to CodSpeed. - name: Keep the measurements From 368d1a006b877e2feda6982b561f8901471a92d0 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Thu, 26 Nov 2026 21:43:09 +0100 Subject: [PATCH 3/6] Keep the CodSpeed files with the fork's other CI files The driver moves to .github/elide and the workflow is named elide-codspeed.yml, so that everything the fork adds is recognisable. --- .github/{scripts => elide}/codspeed_bench.py | 2 +- .github/workflows/{codspeed.yml => elide-codspeed.yml} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/{scripts => elide}/codspeed_bench.py (99%) rename .github/workflows/{codspeed.yml => elide-codspeed.yml} (98%) diff --git a/.github/scripts/codspeed_bench.py b/.github/elide/codspeed_bench.py similarity index 99% rename from .github/scripts/codspeed_bench.py rename to .github/elide/codspeed_bench.py index 48cedacc0f..fd435c9e09 100644 --- a/.github/scripts/codspeed_bench.py +++ b/.github/elide/codspeed_bench.py @@ -40,7 +40,7 @@ # ================================ # # Runs benchmarks from graalpython/com.oracle.graal.python.benchmarks with the upstream harness and -# reports steady-state wall time to CodSpeed. Used by .github/workflows/codspeed.yml; runs on CPython. +# reports steady-state wall time to CodSpeed. Used by .github/workflows/elide-codspeed.yml; runs on CPython. # # Every benchmark runs in its own process of the interpreter under test. The harness prints one # duration per iteration; the first half of the iterations is warm-up and the second half are the diff --git a/.github/workflows/codspeed.yml b/.github/workflows/elide-codspeed.yml similarity index 98% rename from .github/workflows/codspeed.yml rename to .github/workflows/elide-codspeed.yml index 83b0c59b3b..15c845dda4 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/elide-codspeed.yml @@ -97,7 +97,7 @@ jobs: GRAALPY="$RUNNER_TEMP/GRAALPY_NATIVE_STANDALONE/bin/graalpy" "$GRAALPY" -c 'import sys; print(sys.version)' # The last two call C API functions that the public headers do not declare. - python3 .github/scripts/codspeed_bench.py --python "$GRAALPY" \ + python3 .github/elide/codspeed_bench.py --python "$GRAALPY" \ --bench '^micro-native/(c-instantiate-large|c-to-c|c-call-method-obj-args)$' walltime: @@ -136,7 +136,7 @@ jobs: mode: walltime runner-version: "5.2.1" run: >- - python3 .github/scripts/codspeed_bench.py + python3 .github/elide/codspeed_bench.py --python "${{ runner.temp }}/GRAALPY_NATIVE_STANDALONE/bin/graalpy" --suite micro-native meso --output "${{ env.BENCH_OUTPUT }}" From 1188f575ff9fc248b5c7e9044e8f7af70dc04223 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Thu, 26 Nov 2026 21:43:09 +0100 Subject: [PATCH 4/6] Name the benchmark driver without an extension The upstream style job requires an Oracle copyright header in every tracked .py file. The driver is not Oracle's code, so it drops the copied header and its extension, like the fork's other CI scripts. --- .../{codspeed_bench.py => codspeed-bench} | 42 +------------------ .github/workflows/elide-codspeed.yml | 4 +- 2 files changed, 3 insertions(+), 43 deletions(-) rename .github/elide/{codspeed_bench.py => codspeed-bench} (84%) mode change 100644 => 100755 diff --git a/.github/elide/codspeed_bench.py b/.github/elide/codspeed-bench old mode 100644 new mode 100755 similarity index 84% rename from .github/elide/codspeed_bench.py rename to .github/elide/codspeed-bench index fd435c9e09..4128568034 --- a/.github/elide/codspeed_bench.py +++ b/.github/elide/codspeed-bench @@ -1,44 +1,4 @@ -# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# The Universal Permissive License (UPL), Version 1.0 -# -# Subject to the condition set forth below, permission is hereby granted to any -# person obtaining a copy of this software, associated documentation and/or -# data (collectively the "Software"), free of charge and under any and all -# copyright rights in the Software, and any and all patent rights owned or -# freely licensable by each licensor hereunder covering either (i) the -# unmodified Software as contributed to or provided by such licensor, or (ii) -# the Larger Works (as defined below), to deal in both -# -# (a) the Software, and -# -# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if -# one is included with the Software each a "Larger Work" to which the Software -# is contributed by such licensors), -# -# without restriction, including without limitation the rights to copy, create -# derivative works of, display, perform, and distribute the Software and make, -# use, sell, offer for sale, import, export, have made, and have sold the -# Software and the Larger Work(s), and to sublicense the foregoing rights on -# either these or other terms. -# -# This license is subject to the following condition: -# -# The above copyright notice and either this complete permission notice or at a -# minimum a reference to the UPL must be included in all copies or substantial -# portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -# ================================ -# +#!/usr/bin/env python3 # Runs benchmarks from graalpython/com.oracle.graal.python.benchmarks with the upstream harness and # reports steady-state wall time to CodSpeed. Used by .github/workflows/elide-codspeed.yml; runs on CPython. # diff --git a/.github/workflows/elide-codspeed.yml b/.github/workflows/elide-codspeed.yml index 15c845dda4..f2258d065f 100644 --- a/.github/workflows/elide-codspeed.yml +++ b/.github/workflows/elide-codspeed.yml @@ -97,7 +97,7 @@ jobs: GRAALPY="$RUNNER_TEMP/GRAALPY_NATIVE_STANDALONE/bin/graalpy" "$GRAALPY" -c 'import sys; print(sys.version)' # The last two call C API functions that the public headers do not declare. - python3 .github/elide/codspeed_bench.py --python "$GRAALPY" \ + python3 .github/elide/codspeed-bench --python "$GRAALPY" \ --bench '^micro-native/(c-instantiate-large|c-to-c|c-call-method-obj-args)$' walltime: @@ -136,7 +136,7 @@ jobs: mode: walltime runner-version: "5.2.1" run: >- - python3 .github/elide/codspeed_bench.py + python3 .github/elide/codspeed-bench --python "${{ runner.temp }}/GRAALPY_NATIVE_STANDALONE/bin/graalpy" --suite micro-native meso --output "${{ env.BENCH_OUTPUT }}" From 5e70ad5325ee52ea38425b5499eb7152e099b375 Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Thu, 26 Nov 2026 21:57:57 +0100 Subject: [PATCH 5/6] Run the benchmarks on pushes to develop develop is the branch the fork's changes are merged into; master only mirrors upstream. --- .github/workflows/elide-codspeed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/elide-codspeed.yml b/.github/workflows/elide-codspeed.yml index f2258d065f..027cf367b6 100644 --- a/.github/workflows/elide-codspeed.yml +++ b/.github/workflows/elide-codspeed.yml @@ -12,7 +12,7 @@ name: CodSpeed benchmarks # and the measurement run on self-hosted runners. on: push: - branches: [master, 'elide-*.x'] + branches: [develop, 'elide-*.x'] pull_request: types: [opened, synchronize, reopened, labeled] workflow_dispatch: From c8983fa8a8b426070aaafaedb1ffa92021f9d2fc Mon Sep 17 00:00:00 2001 From: Ivo Horak Date: Fri, 27 Nov 2026 10:05:02 +0100 Subject: [PATCH 6/6] CodSpeed: check the standalone on the pool and describe the workflow --- .github/elide/README.md | 11 +++++++++++ .github/workflows/elide-codspeed.yml | 10 ++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/elide/README.md b/.github/elide/README.md index 8b3a563169..1675e8d873 100644 --- a/.github/elide/README.md +++ b/.github/elide/README.md @@ -40,6 +40,17 @@ work on GitHub. The comments in the workflow say why. - The build of the native standalone that all tests run on. - GraalPy's own Python tests, including the C API tests, on the native standalone. +## Benchmarks + +`elide-codspeed.yml` measures the wall time of GraalPy's C API micro benchmarks and pure Python +meso benchmarks on a native standalone and reports it to CodSpeed +(https://app.codspeed.io/elide-dev/graalpython). It runs on pushes to `develop` and `elide-*.x`, +and on pull requests that carry the label `perf:bench`. `codspeed-bench` is the driver that runs +the benchmarks and writes the results. + +The standalone is built on the pool. The measurement runs on the benchmark runner with the label +`linux-amd64-bench`, which is shared between repositories, so only the measurement runs there. + ## Runners All jobs run on Elide's runners, the pool with the label `linux-amd64-cipool`. Set the repository diff --git a/.github/workflows/elide-codspeed.yml b/.github/workflows/elide-codspeed.yml index 027cf367b6..05889e47c7 100644 --- a/.github/workflows/elide-codspeed.yml +++ b/.github/workflows/elide-codspeed.yml @@ -75,15 +75,17 @@ jobs: retention-days: 1 if-no-files-found: error - # The standalone was built on another machine, and the C API benchmarks compile an extension when - # they start. Check both on a hosted runner before the benchmark host is occupied. No timing is - # taken from this job. + # The C API benchmarks compile an extension when they start. Check that the standalone runs and + # that this works before the benchmark host is occupied. No timing is taken from this job. check: name: check standalone needs: build - runs-on: ubuntu-24.04 + runs-on: ${{ vars.CODSPEED_BUILD_RUNNER || 'linux-amd64-cipool' }} timeout-minutes: 30 steps: + - name: Clean workspace + run: find "${GITHUB_WORKSPACE:?}" -mindepth 1 -maxdepth 1 -exec rm -rf {} + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0