From 22b77574201cdc6a2187ed90a31f84dea4133de4 Mon Sep 17 00:00:00 2001 From: cflmy Date: Sun, 22 Nov 2026 22:14:07 +0800 Subject: [PATCH] Compare fixed-node performance without promoting shared CI timings --- .woodpecker/performance.yml | 30 +++++++++++++++++++----------- tools/perf/README.md | 18 +++++++++++++++--- tools/perf/runner.py | 15 ++++++++++++++- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/.woodpecker/performance.yml b/.woodpecker/performance.yml index 72013b3..ef660fc 100644 --- a/.woodpecker/performance.yml +++ b/.woodpecker/performance.yml @@ -1,11 +1,5 @@ -# G4 fixed performance node. -# -# Manual only: this workflow never runs on push or pull_request and therefore -# never executes untrusted PR code on the designated performance agent. The -# repository currently has one Woodpecker agent (agent_id 1), so it is the -# fixed node; the CPU affinity and hardware/toolchain manifest are recorded in -# every report. Do not compare its timings with another machine or with -# QEMU/TCG. +# Manual performance comparison on the shared Woodpecker runner. +# G4 release evidence is measured separately on the approved dedicated node. when: event: [manual] branch: [master] @@ -15,18 +9,29 @@ steps: image: rust:1.100-bookworm commands: - apt-get update - - apt-get install -y --no-install-recommends python3 util-linux ca-certificates + - apt-get install -y --no-install-recommends python3 util-linux ca-certificates git build-essential - cargo build --release --locked -p marqdo-cli - | set -eu + baseline_sha=2c7c4f31e7a388d3fcfa717a77067e696ed13854 + git fetch --no-tags origin refs/tags/v3.0.0-beta.1 + test "$(git rev-parse 'FETCH_HEAD^{commit}')" = "$baseline_sha" + perf_dir="$(mktemp -d)" + git worktree add --detach "$perf_dir/beta" "$baseline_sha" + trap 'git worktree remove --force "$perf_dir/beta"; rm -rf "$perf_dir"' EXIT + (cd "$perf_dir/beta" && cargo build --release --locked -p marqdo-cli) + allowed="$(awk '/^Cpus_allowed_list:/ {print $2}' /proc/self/status)" cpu_list="${MARQDO_PERF_CPU_LIST:-$(printf '%s' "$allowed" | cut -d, -f1 | cut -d- -f1)}" echo "G4_NODE host=$(uname -n) kernel=$(uname -r) arch=$(uname -m) allowed_cpus=$allowed pin=$cpu_list" echo "G4_CPU $(awk -F: '/model name/ {print $2; exit}' /proc/cpuinfo | xargs)" echo "G4_GOVERNOR $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null || echo unavailable)" + (cd "$perf_dir/beta" && python3 tools/perf/runner.py --no-build \ + --warmups 5 --samples 20 --platform-id woodpecker-agent-1 \ + --cpu-list "$cpu_list" --out "$perf_dir/beta.json" > /dev/null) python3 tools/perf/runner.py --no-build --warmups 5 --samples 20 \ - --approved-node --platform-id woodpecker-agent-1 \ - --cpu-list "$cpu_list" --out perf.json + --platform-id woodpecker-agent-1 --cpu-list "$cpu_list" \ + --baseline "$perf_dir/beta.json" --out perf.json > /dev/null python3 - <<'PY' import json @@ -47,6 +52,9 @@ steps: f"rss={workload.get('max_rss_kb_median')}" ) PY + echo "G4_BASELINE_REPORT_BEGIN" + cat "$perf_dir/beta.json" + echo "G4_BASELINE_REPORT_END" echo "G4_REPORT_BEGIN" cat perf.json echo "G4_REPORT_END" diff --git a/tools/perf/README.md b/tools/perf/README.md index a46747e..c6f0af2 100644 --- a/tools/perf/README.md +++ b/tools/perf/README.md @@ -13,9 +13,10 @@ workload whose wire output did not match the committed expected digest. * Release evidence needs at least 5 warmups and 20 samples per workload with `--approved-node` on a dedicated, stable performance node. Shorter runs are `SMOKE` and must not be cited as a release gate. -* Do not compare timings across different `platform_id`s, CPU models, kernels, - toolchains or load conditions. `--baseline` refuses a different - `platform_id`/profile. +* `--baseline` checks platform ID, build profile, CPU model, kernel, + governor, CPU affinity and toolchain. For an approved-node comparison + it also requires an approved, correctness-verified MEASURED baseline. + Record competing load and investigate differences before sign-off. * Avoid TCG/QEMU for final performance numbers; use native or KVM with fixed CPU affinity (`--cpu-list`) and an administrator-approved governor. * The suggested investigation thresholds are p50 +15% and peak RSS +20%; they @@ -43,3 +44,14 @@ source. Running `--record-expected` rewrites them: inspect the diff and commit it only when the output change is the intended one. `bench.py` remains only as a compatibility shim. + +## RC comparison + +On the approved dedicated node, run the beta benchmark from a checkout +pinned to `v3.0.0-beta.1` and the candidate benchmark from the frozen +candidate checkout. Use the same toolchain, CPU list and platform ID in both +commands. Pass the extracted, verified candidate CLI via `--no-build --binary` +and add `--baseline /path/to/beta.json` to the candidate command. Keep both +reports and confirm all nine comparisons are present and correctness-verified. +The shared Woodpecker manual workflow runs the same comparison as a diagnostic +and produces SMOKE reports. diff --git a/tools/perf/runner.py b/tools/perf/runner.py index ddec9c1..ed90903 100755 --- a/tools/perf/runner.py +++ b/tools/perf/runner.py @@ -339,6 +339,18 @@ def compare_baseline(report: dict, baseline: dict) -> list[dict]: ) if baseline.get("binary", {}).get("profile") != report.get("binary", {}).get("profile"): raise SystemExit("baseline profile differs") + for field in ("kernel", "machine", "cpu_model", "governor", "cpu_list"): + if baseline["environment"].get(field) != report["environment"].get(field): + raise SystemExit(f"baseline environment.{field} differs") + for field in ("rustc", "cargo"): + if baseline["binary"].get(field) != report["binary"].get(field): + raise SystemExit(f"baseline binary.{field} differs") + if report["environment_approved"] and ( + not baseline.get("environment_approved") + or baseline.get("status") != "MEASURED" + or baseline.get("correctness") != "VERIFIED" + ): + raise SystemExit("approved-node comparison requires an approved, verified MEASURED baseline") previous = {item["name"]: item for item in baseline.get("workloads", [])} comparisons = [] for current in report["workloads"]: @@ -415,6 +427,7 @@ def main(argv: list[str]) -> int: order_seed = hashlib.sha256(source_sha.encode()).hexdigest()[:16] order = list(workloads) random.Random(order_seed).shuffle(order) + start_load = loadavg() results = [] for workload in order: result = run_workload( @@ -461,7 +474,7 @@ def main(argv: list[str]) -> int: "machine": platform.machine(), "cpu_model": cpu_model(), "governor": governor(), - "loadavg_start": loadavg(), + "loadavg_start": start_load, "cpu_list": args.cpu_list or "unbound", "python": platform.python_version(), },