Skip to content

fix(ci): compile the criterion benches without release optimization - #2320

Merged
robcohen merged 1 commit into
mainfrom
fix/bench-compile-memory
Sep 14, 2026
Merged

robcohen merged 1 commit into
mainfrom
fix/bench-compile-memory

Conversation

@robcohen

@robcohen robcohen commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Benchmarks Compile only checks that the benches compile (cargo bench --workspace --no-run); nothing in CI runs them. But cargo bench inherits the release profile (codegen-units = 1, thin LTO), and this repo adds debug = true, so every run built fully optimized, fully debug-annotated binaries that never execute.

This PR builds that step without the optimization:

CARGO_PROFILE_BENCH_LTO: "false"
CARGO_PROFILE_BENCH_CODEGEN_UNITS: "16"
CARGO_PROFILE_BENCH_DEBUG: "false"

Why now

On 2026-09-14 the job was killed on 9 of its 15 runs, across #2306, #2308 and two dependabot PRs: The runner has received a shutdown signal / exit 143, with no compiler error. Every kill came 4–9 minutes into the link phase, which prints nothing and takes 17–21 minutes when the job completes. No other job was killed out of the day's 1,053. The required build check aggregates this job, so each affected PR was blocked.

Ruled out from the logs:

  • Runner or image change: runner version, hosted compute agent, Azure region and runner image were identical on passing and killed runs.
  • Disk: the whole bench target directory is under 3 GB.
  • Cache: every run restored the same 793 MB rust-cache.
  • A GitHub incident: none posted for that day.

Measured

Locally, with 4 jobs to match the runner's vCPUs, building the same 17 bench executables:

time peak system memory largest rustc
as configured 19m 36s 12.0 GB 3.1 GB
this change 6m 42s 5.7 GB 1.3 GB

The configured build's duration matches CI's passing runs, and its peak falls where the runners were killed. That supports a memory limit on a 16 GB runner, but doesn't prove one. The change stands regardless: the same compile check, in a third of the time and less than half the memory.

Validated on a real runner

This PR's own CI skips Benchmarks Compile. The changes path filter counts *.rs, Cargo files and tests as code, not .github/workflows/**, so a PR that only edits ci.yml never runs the job it changes. To exercise it anyway, CI was dispatched manually on this branch (workflow_dispatch always builds): run 34877539480.

  • The env reached the step: CARGO_PROFILE_BENCH_LTO: false, CARGO_PROFILE_BENCH_CODEGEN_UNITS: 16, CARGO_PROFILE_BENCH_DEBUG: false.
  • Cargo confirms the new profile: Finished bench profile [optimized] target(s) in 9m 00s, with no + debuginfo.
  • Same output, no failures: the same 17 bench executables, 0 shutdown signals, 0 compiler errors.

That 9 minutes is a cold build (sccache: 26 hits, 540 misses). The new flags invalidate every cached artifact, so every dependency was rebuilt. Once main has saved caches under these settings, the job should be faster still.

Unrelated failing checks

Cargo Deny, and quality which aggregates it, fail on RUSTSEC-2026-0285, a TLS 1.3 advisory that started failing every PR in the Quality workflow at about 16:00 on 2026-09-14. It has nothing to do with this change, and neither check is required.

Scope

Only the one step. Release builds are untouched, and so is PR Benchmarks, which builds --release and times it with hyperfine and never uses the bench profile.

🤖 Generated with Claude Code

`Benchmarks Compile` only checks that the benches compile — it runs
`cargo bench --workspace --no-run`, and nothing in CI ever executes the
result. But `cargo bench` inherits the release profile (`codegen-units = 1`,
thin LTO) and the repo adds `debug = true`, so every run paid for fully
optimized, fully debug-annotated binaries nobody runs.

That cost became a failure on 2026-09-14. The job was killed with "The runner
has received a shutdown signal" / exit 143 on 9 of its 15 runs that day,
across four PRs (#2306, #2308 and two dependabot PRs), always 4–9 minutes
into the silent link phase that takes 17–21 minutes when it completes. None
of the day's other 1,053 jobs was killed. Runner version, compute agent,
region and image were identical on passing and killed runs; the target dir
is under 3 GB, so it is not disk. Because the required `build` check
aggregates this job, every affected PR was unmergeable.

Measured locally with 4 jobs, matching the runner's vCPUs, same 17 bench
executables:

  as configured          19m36s   peak 12.0 GB system   largest rustc 3.1 GB
  this change             6m42s   peak  5.7 GB system   largest rustc 1.3 GB

The configured build's duration matches CI's passing runs, and its peak lands
where the runners died. That supports a memory limit on a 16 GB runner
without proving it, but the change is right on its own terms: the same
compile check, a third of the time, less than half the memory.

Scoped to that one step. Release builds, and PR Benchmarks — which builds
`--release` and times it with hyperfine — are untouched.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
@robcohen
robcohen requested a review from a team as a code owner September 14, 2026 17:52
Copilot AI lite review requested due to automatic review settings September 14, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Add CARGO_PROFILE_BENCH_OPT_LEVEL: "0" before approval.

Pull request overview

This PR reduces resource usage for the compile-only CI benchmark step without affecting release builds or benchmark execution.

Changes:

  • Disables bench-profile LTO and debug info.
  • Increases bench codegen units to 16.
  • Documents CI failures and measured resource savings.
File summaries
File Summary
.github/workflows/ci.yml Adjusts benchmark compilation settings; the bench profile still requires opt-level = 0 to avoid release-level optimization.
Review details

Suppressed comments (1)

.github/workflows/ci.yml:671

  • [profile.bench] still inherits the release profile's opt-level = 3; these overrides only disable LTO/debug info and increase codegen units, so rustc still performs full per-unit release optimization. Since this job only checks compilation, add CARGO_PROFILE_BENCH_OPT_LEVEL: "0" to actually avoid the release optimization described by this change.
          CARGO_PROFILE_BENCH_LTO: "false"
          CARGO_PROFILE_BENCH_CODEGEN_UNITS: "16"
          CARGO_PROFILE_BENCH_DEBUG: "false"
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 99% (raw 93%, 169 masked)
Full AST Match 100%
Total Files 813
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@robcohen
robcohen merged commit daf05cc into main Sep 14, 2026
72 of 74 checks passed
@robcohen
robcohen deleted the fix/bench-compile-memory branch September 14, 2026 18:13
robcohen added a commit to NikodemMarek/rustledger that referenced this pull request Sep 15, 2026
…d-postings

Brings the branch up to date. The base predated rustledger#2320, so the required
`build` check failed on the Benchmarks Compile runner being killed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants