diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index c7afb638c3f..a5509aebf40 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,9 +21,20 @@ env: permissions: {} jobs: + runner-probe: + name: Probe CodSpeed runner + if: github.event_name == 'workflow_dispatch' && inputs.runner_probe + runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04 + timeout-minutes: 2 + steps: + - name: Verify the ARM64 runner is available + run: test "$(uname -m)" = aarch64 + codspeed: name: CodSpeed - runs-on: ubuntu-latest + if: inputs.runner_probe != true + timeout-minutes: 60 + runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04 outputs: run-id: ${{ steps.benchmarks.outputs.run-id }} permissions: @@ -39,19 +55,20 @@ 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 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/CONTRIBUTING.md b/CONTRIBUTING.md index b178404a8a2..1eac4e7021c 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 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. +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..5237aaedbb1 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/); @@ -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"); } }); @@ -165,3 +165,34 @@ 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-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/); + 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/); +}); + + +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); +});