Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/celox/benches/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(), || {
Expand Down
37 changes: 34 additions & 3 deletions scripts/benchmark-workflows.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
Expand All @@ -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");
}
});

Expand Down Expand Up @@ -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);
});
Loading