From 7d1dbebe3c07bcad3cef243dd3dfb11093dfa52e Mon Sep 17 00:00:00 2001 From: tignear Date: Sun, 25 Oct 2026 05:28:09 +0900 Subject: [PATCH 1/3] ci: measure compilation benchmarks with CodSpeed walltime Change-Id: I99da4b4abb1f9113e2e89fa9cbe3bb0ea9a06b0b --- .github/workflows/codspeed.yml | 10 ++++++---- CONTRIBUTING.md | 10 ++++++++-- crates/celox/benches/compilation.rs | 2 +- scripts/benchmark-workflows.test.mjs | 14 +++++++++++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index c7afb638c3f..0830b896d1b 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -18,7 +18,8 @@ permissions: {} jobs: codspeed: name: CodSpeed - runs-on: ubuntu-latest + timeout-minutes: 60 + runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04 outputs: run-id: ${{ steps.benchmarks.outputs.run-id }} permissions: @@ -39,14 +40,15 @@ jobs: tool: cargo-codspeed@5.0.1 - name: Build compile-time benchmarks - run: cargo codspeed build --locked -p celox --bench compilation + run: cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation - name: Run compile-time benchmarks id: benchmarks + timeout-minutes: 15 uses: CodSpeedHQ/action@v5 with: - mode: simulation - run: cargo codspeed run -p celox + mode: walltime + run: cargo codspeed run --measurement-mode walltime -p celox --bench compilation report: name: Report CodSpeed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b178404a8a2..ef4e1632899 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,6 +107,12 @@ interpreter, native and Cranelift backends in both two-state and four-state mode wide-value latch checks, and a small sorter compilation smoke test. The 257/512-bit per-bit graph cases and sorter sizes 4/8/16/32 are measured by `benches/compilation.rs` in the existing daily/manual CodSpeed workflow. +Compilation benchmarks use CodSpeed walltime measurement on its x64 Ryzen +Macro Runner: CPU simulation made +a single 512-bit case take tens of minutes. The benchmark step has a 15-minute +timeout and the complete job a 60-minute limit; a timeout is reported as failure. +The organization runner group must allow this public repository to use CodSpeed +Macro Runners. Simulation and walltime measurements have separate baselines. Nested-write benchmarks reuse the same semantic assertions as the small tests. Scaling cases use one iteration without per-case warmups or adaptive sampling; a small counter warms process-global analyzer state before measurement. @@ -117,8 +123,8 @@ CodSpeed reporting workflow. Build and run them with the same CodSpeed harness as CI: ```sh -cargo codspeed build --locked -p celox --bench compilation -cargo codspeed run -p celox +cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation +cargo codspeed run --measurement-mode walltime -p celox --bench compilation ``` ## Finish validation diff --git a/crates/celox/benches/compilation.rs b/crates/celox/benches/compilation.rs index d99104ba6c7..984d896b73d 100644 --- a/crates/celox/benches/compilation.rs +++ b/crates/celox/benches/compilation.rs @@ -58,7 +58,7 @@ fn benchmark_scaling(c: &mut Criterion) { // Warm analyzer state before any measured span, including filtered runs. compile_default(COUNTER, "Top", Some(("N", 1))); // Each large design runs once: no five-run warmup or adaptive resampling. - // CodSpeed simulation measures one iteration; walltime uses the same schedule. + // Walltime uses this fixed schedule even for the largest graphs. for n in [4, 8, 16, 32] { c.bench_function(&format!("compile/sorter_tree/n{n}"), |b| { b.iter_manual_unstable(IterManualOptions::new(), || { diff --git a/scripts/benchmark-workflows.test.mjs b/scripts/benchmark-workflows.test.mjs index 5f58b398e90..f0ccd37de28 100644 --- a/scripts/benchmark-workflows.test.mjs +++ b/scripts/benchmark-workflows.test.mjs @@ -50,7 +50,7 @@ test("CodSpeed reports the current upload even after failure or cancellation", ( const benchmark = job(codspeed, "codspeed"); const report = job(codspeed, "report"); assert.match(benchmark, /run-id: \$\{\{ steps\.benchmarks\.outputs\.run-id \}\}/); - assert.match(benchmark, /id: benchmarks\n\s+uses: CodSpeedHQ\/action@v5/); + assert.match(benchmark, /id: benchmarks\n\s+timeout-minutes: 15\n\s+uses: CodSpeedHQ\/action@v5/); assert.match(report, /needs: codspeed/); assert.match(report, /checks: read/); assert.match(report, /issues: write/); @@ -165,3 +165,15 @@ test("profiling reuse rejects pre-CLI artifacts before capture", () => { assert.match(check, /predates the celox run CLI/); assert.match(check, /exit 1/); }); + + +test("compilation scaling uses walltime consistently and has a bounded execution", () => { + const benchmark = job(codspeed, "codspeed"); + assert.match(benchmark, /runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04/); + assert.match(benchmark, /timeout-minutes: 60/); + assert.match(benchmark, /cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation/); + assert.match(benchmark, /id: benchmarks\n timeout-minutes: 15\n uses: CodSpeedHQ\/action@v5/); + assert.match(benchmark, /mode: walltime/); + assert.match(benchmark, /run: cargo codspeed run --measurement-mode walltime -p celox --bench compilation/); + assert.doesNotMatch(benchmark, /simulation|continue-on-error/); +}); From 8f35ef1974aac1ead77feadf1951d0db354fc7d9 Mon Sep 17 00:00:00 2001 From: tignear Date: Sun, 25 Oct 2026 05:30:48 +0900 Subject: [PATCH 2/3] ci: add a build-free CodSpeed runner probe Change-Id: I34c27f4234479a98dd5a1f2e45826759af799672 --- .github/workflows/codspeed.yml | 17 ++++++++++++++++- scripts/benchmark-workflows.test.mjs | 23 +++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index 0830b896d1b..b2e70046aa3 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -4,6 +4,11 @@ on: schedule: - cron: "17 2 * * *" workflow_dispatch: + inputs: + runner_probe: + description: Check Macro Runner availability without building or benchmarking + type: boolean + default: false concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -16,8 +21,18 @@ env: permissions: {} jobs: + runner-probe: + name: Probe CodSpeed runner + if: github.event_name == 'workflow_dispatch' && inputs.runner_probe + runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04 + timeout-minutes: 2 + steps: + - name: Verify the x64 runner is available + run: test "$(uname -m)" = x86_64 + codspeed: name: CodSpeed + if: inputs.runner_probe != true timeout-minutes: 60 runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04 outputs: @@ -53,7 +68,7 @@ jobs: report: name: Report CodSpeed needs: codspeed - if: always() && (github.ref_name == 'master' || github.ref_name == 'develop') + if: always() && inputs.runner_probe != true && (github.ref_name == 'master' || github.ref_name == 'develop') runs-on: ubuntu-latest timeout-minutes: 10 permissions: diff --git a/scripts/benchmark-workflows.test.mjs b/scripts/benchmark-workflows.test.mjs index f0ccd37de28..cc3e564932a 100644 --- a/scripts/benchmark-workflows.test.mjs +++ b/scripts/benchmark-workflows.test.mjs @@ -59,9 +59,9 @@ test("CodSpeed reports the current upload even after failure or cancellation", ( assert.match(report, /run: node scripts\/report-codspeed\.mjs/); assert.doesNotMatch(codspeed, /continue-on-error:/); assert.match(codspeed, /cancel-in-progress: false/); - const condition = new Function("github", "always", `return (${expression(report, "if")});`); + const condition = new Function("github", "always", "inputs", `return (${expression(report, "if")});`); for (const branch of ["master", "develop", "feature"]) { - assert.equal(condition({ ref_name: branch }, () => true), branch !== "feature"); + assert.equal(condition({ ref_name: branch }, () => true, { runner_probe: false }), branch !== "feature"); } }); @@ -177,3 +177,22 @@ test("compilation scaling uses walltime consistently and has a bounded execution assert.match(benchmark, /run: cargo codspeed run --measurement-mode walltime -p celox --bench compilation/); assert.doesNotMatch(benchmark, /simulation|continue-on-error/); }); + + +test("runner probe cannot build or benchmark and does not report a skipped benchmark as failure", () => { + const probe = job(codspeed, "runner-probe"); + const runner = block => block.match(/runs-on: (\S+)/)[1]; + assert.equal(runner(probe), runner(job(codspeed, "codspeed"))); + assert.doesNotMatch(probe, /checkout|cargo|CodSpeedHQ\/action/); + assert.match(probe, /timeout-minutes: 2/); + const probeCondition = new Function("github", "inputs", `return (${expression(probe, "if")});`); + const benchCondition = new Function("inputs", `return (${expression(job(codspeed, "codspeed"), "if")});`); + const reportCondition = new Function("github", "inputs", "always", `return (${expression(job(codspeed, "report"), "if")});`); + for (const runner_probe of [true, false]) { + const inputs = { runner_probe }; + assert.equal(Boolean(probeCondition({ event_name: "workflow_dispatch" }, inputs)), runner_probe); + assert.equal(benchCondition(inputs), !runner_probe); + assert.equal(reportCondition({ ref_name: "master" }, inputs, () => true), !runner_probe); + } + assert.equal(benchCondition({}), true); +}); From eb08d878c884902151fcc4f4173a044049fbf32f Mon Sep 17 00:00:00 2001 From: tignear Date: Sun, 25 Oct 2026 05:33:32 +0900 Subject: [PATCH 3/3] ci: use the standard Graviton CodSpeed macro runner Change-Id: Ibcbf8e2b9f1a510006e52d7d3a26fed166f30bae --- .github/workflows/codspeed.yml | 8 ++++---- CONTRIBUTING.md | 2 +- scripts/benchmark-workflows.test.mjs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index b2e70046aa3..a5509aebf40 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -24,17 +24,17 @@ jobs: runner-probe: name: Probe CodSpeed runner if: github.event_name == 'workflow_dispatch' && inputs.runner_probe - runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04 + runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04 timeout-minutes: 2 steps: - - name: Verify the x64 runner is available - run: test "$(uname -m)" = x86_64 + - name: Verify the ARM64 runner is available + run: test "$(uname -m)" = aarch64 codspeed: name: CodSpeed if: inputs.runner_probe != true timeout-minutes: 60 - runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04 + runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04 outputs: run-id: ${{ steps.benchmarks.outputs.run-id }} permissions: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef4e1632899..1eac4e7021c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,7 +107,7 @@ interpreter, native and Cranelift backends in both two-state and four-state mode wide-value latch checks, and a small sorter compilation smoke test. The 257/512-bit per-bit graph cases and sorter sizes 4/8/16/32 are measured by `benches/compilation.rs` in the existing daily/manual CodSpeed workflow. -Compilation benchmarks use CodSpeed walltime measurement on its x64 Ryzen +Compilation benchmarks use CodSpeed walltime measurement on its ARM64 Graviton Macro Runner: CPU simulation made a single 512-bit case take tens of minutes. The benchmark step has a 15-minute timeout and the complete job a 60-minute limit; a timeout is reported as failure. diff --git a/scripts/benchmark-workflows.test.mjs b/scripts/benchmark-workflows.test.mjs index cc3e564932a..5237aaedbb1 100644 --- a/scripts/benchmark-workflows.test.mjs +++ b/scripts/benchmark-workflows.test.mjs @@ -169,7 +169,7 @@ test("profiling reuse rejects pre-CLI artifacts before capture", () => { test("compilation scaling uses walltime consistently and has a bounded execution", () => { const benchmark = job(codspeed, "codspeed"); - assert.match(benchmark, /runs-on: codspeed-macro-x64-ryzen-9950x-ubuntu-24-04/); + assert.match(benchmark, /runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04/); assert.match(benchmark, /timeout-minutes: 60/); assert.match(benchmark, /cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation/); assert.match(benchmark, /id: benchmarks\n timeout-minutes: 15\n uses: CodSpeedHQ\/action@v5/);