Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ workflows:
- 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066'
'.github/workflows/codspeed.yml':
- 'actions/checkout@v7'
- 'actions/setup-python@v7'
- 'codspeedhq/action@v5'
- 'dtolnay/rust-toolchain@master'
- 'swatinem/rust-cache@v2'
Expand Down
80 changes: 70 additions & 10 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
name: Compile-time Benchmarks
name: CodSpeed Benchmarks

# Compile-time, scheduler-scaling and RTLMeter benchmarks on CodSpeed's ARM64
# Macro Runner (walltime). Every push to master is measured, so a regression
# shows on its commit; a pull request is measured only with the `bench` label
# (`bench-blackparrot` adds the BlackParrot case) because a run takes one to
# two hours of the runner.
on:
schedule:
- cron: "17 2 * * *"
push:
branches: [master]
Comment thread
tignear marked this conversation as resolved.
Resolved
paths-ignore:
- "docs/**"
- "**/*.md"
pull_request:
types: [opened, reopened, synchronize, labeled]
workflow_dispatch:
inputs:
runner_probe:
description: Check Macro Runner availability without building or benchmarking
type: boolean
default: false
blackparrot:
description: Also measure BlackParrot 1x1 CoreMark (about an hour more)
type: boolean
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
# One group per commit outside pull requests: GitHub keeps only one pending
# run per group, so a shared master group would drop the measurements of a
# burst of pushes. A newer push to a pull request replaces its older run.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_BENCH_DEBUG: "0"
# Fat LTO links of four celox binaries (three benchmarks and the CLI) at
# once, with the debug info CodSpeed adds, starved the 32 GB Cortex-A72
# runner until it lost its connection (and took over 40 minutes).
CARGO_PROFILE_BENCH_LTO: thin
PYTHONDONTWRITEBYTECODE: "1"

permissions: {}

Expand All @@ -32,14 +56,35 @@ jobs:

codspeed:
name: CodSpeed
if: inputs.runner_probe != true
timeout-minutes: 60
# A pull request runs only with a benchmark label, and adding another
# label does not start it again.
if: >-
inputs.runner_probe != true && (github.event_name != 'pull_request' ||
((contains(github.event.pull_request.labels.*.name, 'bench') ||
contains(github.event.pull_request.labels.*.name, 'bench-blackparrot')) &&
(github.event.action != 'labeled' || github.event.label.name == 'bench' ||
github.event.label.name == 'bench-blackparrot')))
timeout-minutes: 210
runs-on: codspeed-macro-arm64-graviton-ubuntu-22-04
outputs:
run-id: ${{ steps.benchmarks.outputs.run-id }}
permissions:
contents: read
id-token: write
env:
# BlackParrot compiles for about 8 minutes on x86-64 and loads its
# program for about 3 more, several times that on this runner: nightly,
# on request, or with the `bench-blackparrot` label.
BLACKPARROT: ${{ github.event_name == 'schedule' || inputs.blackparrot == true || contains(github.event.pull_request.labels.*.name, 'bench-blackparrot') }}
CELOX_RTLMETER_LAYOUT: ${{ github.workspace }}/work/rtlmeter-layout
# Each RTLMeter run is killed (and fails its benchmark) past 20 GiB
# resident, so one case cannot take the 32 GB runner down.
CELOX_RTLMETER_MEMORY_LIMIT_MIB: "20480"
# The walltime profiler samples every benchmarked process, the celox
# commands of the RTLMeter cases included, copying 8 KiB of stack per
# sample for tens of minutes; with it the runner lost its connection
# during the benchmarks. Measurements do not need it.
CODSPEED_PROFILER_ENABLED: "false"
steps:
- uses: actions/checkout@v7

Expand All @@ -54,16 +99,31 @@ jobs:
with:
tool: cargo-codspeed@5.0.1

- name: Build compile-time benchmarks
run: cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation
- uses: actions/setup-python@v7
with:
python-version: "3.13"

- name: Lay out the pinned RTLMeter cases
run: |
python -m pip install -r benchmarks/rtlmeter/requirements.txt
python scripts/run-rtlmeter-bench.py prepare "$RUNNER_TEMP/rtlmeter"
optional=()
if [ "$BLACKPARROT" = true ]; then optional=(--optional); fi
python scripts/run-rtlmeter-bench.py codspeed-layout "$RUNNER_TEMP/rtlmeter" "$CELOX_RTLMETER_LAYOUT" "${optional[@]}"

- name: Build benchmarks
# `compilation` measures the Cranelift backend too. Memory and disk
# are logged each minute, so a starved runner leaves evidence.
run: bash scripts/with-resource-log.sh cargo codspeed build --locked --measurement-mode walltime -p celox --features cranelift --bench compilation --bench scaling --bench rtlmeter

- name: Run compile-time benchmarks
- name: Run benchmarks
id: benchmarks
timeout-minutes: 15
timeout-minutes: 120
uses: CodSpeedHQ/action@v5
with:
mode: walltime
run: cargo codspeed run --measurement-mode walltime -p celox --bench compilation
# Memory and disk each minute, so a starved runner leaves evidence.
run: bash scripts/with-resource-log.sh cargo codspeed run --measurement-mode walltime -p celox --bench compilation --bench scaling --bench rtlmeter

report:
name: Report CodSpeed
Expand Down
16 changes: 10 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,19 @@ Affected PR and full CI retain small nested-write semantic regressions on
interpreter, native and Cranelift backends in both two-state and four-state modes,
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.
`benches/compilation.rs` in the 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.
a single 512-bit case take tens of minutes. The same job runs `benches/scaling.rs`
and `benches/rtlmeter.rs`; its benchmark step has a 120-minute timeout and the
complete job a 210-minute limit; a timeout is reported as failure. The
benchmarks build with thin LTO: fat LTO of all of them at once starved the
32 GB runner.
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;
Scaling cases run twice (the fewest samples the walltime analysis accepts),
without per-case warmups or adaptive sampling;
a small counter warms process-global analyzer state before measurement.
Sorter sizes are separate CodSpeed measurements; performance comparisons replace
process-time ratio assertions in ordinary tests. Failures use the existing
Expand All @@ -184,7 +188,7 @@ CodSpeed reporting workflow.
Build and run them with the same CodSpeed harness as CI:

```sh
cargo codspeed build --locked --measurement-mode walltime -p celox --bench compilation
cargo codspeed build --locked --measurement-mode walltime -p celox --features cranelift --bench compilation
cargo codspeed run --measurement-mode walltime -p celox --bench compilation
```

Expand Down Expand Up @@ -452,7 +456,7 @@ Local validation uses the behavior-based matrix above.
| Daily at 01:17 UTC (10:17 JST) | Full `ci.yml` on the default branch, with every change-classifier output enabled. Includes native/WASI NAPI, JS/browser tests, ARM64, script tests, and all ordinary Celox workspace tests. |
| Daily from `nightly.yml` at 02:43 UTC (11:43 JST) | Dispatch the same full CI on `develop`, with detection of its Veryl dependency lane. Queue nightly packages. External simulator comparisons and Heliodor are not dispatched on `develop`. |
| Daily at 01:47 UTC (10:47 JST) | `bench.yml` measures Rust, Verilator, and TypeScript on one host and publishes master history. Manual dispatch supports branch measurements. |
| Daily at 02:17 UTC (11:17 JST) | `codspeed.yml` measures compile time on the default branch using CPU simulation. Execution failures and CodSpeed performance-check failures open or update a branch issue; the next healthy run closes it. Manual dispatch supports branch measurements. PRs, merge groups, and pushes do not run CodSpeed. |
| Every push to `master`, daily at 02:17 UTC (11:17 JST), and pull requests labelled `bench` | `codspeed.yml` measures compile time, scheduler scaling, whole-design fallbacks and RTLMeter designs on CodSpeed's ARM64 Macro Runner (walltime); see [Benchmarks](docs/benchmarks/index.md). Execution failures and CodSpeed performance-check failures on `master` and `develop` open or update a branch issue; the next healthy run closes it. Manual dispatch supports branch measurements; BlackParrot runs nightly, on dispatch with `blackparrot`, or with the `bench-blackparrot` label. Other PRs and merge groups do not run CodSpeed. |
| Daily at 02:37 UTC (11:37 JST) | `heliodor-bench.yml` runs the complete master Linux suite on x86-64 and AArch64. Explicit manual selections retain focused suite runs and ARM64 profiling. PRs do not run this workflow; its tooling tests run in `Lint & Format` with the other script tests. |
| Every full CI run | Run the pinned upstream `common_cells` Gray code SV TB through `celox run --project`, plus an assertion negative control. Logs are retained for 14 days and failures feed the Full CI issue. See [the reproduction instructions](conformance/common-cells/README.md). |
| Daily at 03:47 UTC (12:47 JST) on the default branch, and on demand | Independent `external-comparisons.yml` runs every shared Veryl and SystemVerilog case against Verilator, Icarus, and xezim, with locked Nix tools. Run the live adapter tests normally marked ignored because they need external tools. Preserve reports and per-case diagnostics as artifacts for 14 days, including on failure; matrix failures do not cancel the other comparisons. |
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/rtlmeter/codspeed_manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"schemaVersion": 1,
"contract": "rtlmeter-codspeed-v1",
"repository": "https://github.com/verilator/rtlmeter.git",
"revision": "4fdd6c3fd154e9b99d3a9d713cf3f4977e284f94",
"cases": {
"veer-el2-cmark": {
"design": "VeeR-EL2",
"configuration": "default",
"test": "cmark",
"window": 20000,
"rounds": 2
},
"veer-eh1-cmark": {
"design": "VeeR-EH1",
"configuration": "default",
"test": "cmark",
"window": 20000,
"rounds": 2
},
"e906-cmark": {
"design": "XuanTie-E906",
"test": "cmark",
"window": 100000,
"rounds": 2
},
"blackparrot-1x1-cmark": {
"design": "BlackParrot",
"configuration": "1x1",
"test": "cmark",
"window": 20000,
"rounds": 2,
"optional": true,
"diagnostics": [
"mixed_timescale=warn",
"inferred_latch=warn"
]
}
}
}
10 changes: 10 additions & 0 deletions crates/celox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ bench = false
name = "tiered"
harness = false

[[bench]]
name = "scaling"
harness = false

# Needs the RTLMeter layout of `scripts/run-rtlmeter-bench.py codspeed-layout`.
[[bench]]
name = "rtlmeter"
harness = false
bench = false

[[example]]
name = "sv_tests"
path = "examples/sv_tests.rs"
Expand Down
18 changes: 8 additions & 10 deletions crates/celox/benches/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ fn benchmark_compilation(c: &mut Criterion) {
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.
// Walltime uses this fixed schedule even for the largest graphs.
// Each large design runs twice, the fewest samples the walltime analysis
// accepts: no five-run warmup or adaptive resampling. Walltime uses this
// fixed schedule even for the largest graphs.
let twice = IterManualOptions::new().rounds(2);
for n in [4, 8, 16, 32] {
c.bench_function(&format!("compile/sorter_tree/n{n}"), |b| {
b.iter_manual_unstable(IterManualOptions::new(), || {
black_box(sorter_tree::compile(black_box(n)))
});
b.iter_manual_unstable(twice, || black_box(sorter_tree::compile(black_box(n))));
});
}
macro_rules! backend {
Expand All @@ -74,7 +74,7 @@ fn benchmark_scaling(c: &mut Criterion) {
c.bench_function(
&format!("scaling/nested_write/{}/{state}/complete_{width}", $name),
|b| {
b.iter_manual_unstable(IterManualOptions::new(), || {
b.iter_manual_unstable(twice, || {
nested_write::complete!($build, black_box(width), four_state)
})
},
Expand All @@ -83,7 +83,7 @@ fn benchmark_scaling(c: &mut Criterion) {
c.bench_function(
&format!("scaling/nested_write/{}/{state}/incomplete_512", $name),
|b| {
b.iter_manual_unstable(IterManualOptions::new(), || {
b.iter_manual_unstable(twice, || {
nested_write::incomplete!($build, black_box(512), four_state)
})
},
Expand All @@ -95,9 +95,7 @@ fn benchmark_scaling(c: &mut Criterion) {
backend!("native", build_native);
backend!("cranelift", build_cranelift);
c.bench_function("scaling/nested_write/strict_reject_512", |b| {
b.iter_manual_unstable(IterManualOptions::new(), || {
nested_write::strictly_reject(black_box(512))
});
b.iter_manual_unstable(twice, || nested_write::strictly_reject(black_box(512)));
});
}

Expand Down
Loading
Loading