feat(bench): add baseline benchmark capture and CI regression check - #301
feat(bench): add baseline benchmark capture and CI regression check#301aaniya22 wants to merge 2 commits into
Conversation
…ohu-org#287) - Wire mohu-buffer with a Criterion bench target (benches/ndarray_ops.rs), benchmarking Buffer::zeros and Buffer::alloc at 3 sizes. mohu-array's NdArray type is not yet implemented, so this exercises the allocation layer it will be built on. - Capture and commit a baseline (benches/baselines/main.json) via critcmp. - Document how to run/compare benchmarks and the intended NumPy comparison targets in benches/README.md. - Add a non-blocking CI job (bench-compare) that runs benchmarks on PRs and posts a comparison against the committed baseline to the job summary. Signed-off-by: Aaniya <aaniyaatomar@gmail.com>
PR Check Summary
CI will run: build, test, clippy, fmt, cargo-deny, DCO, semver. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Criterion benchmarks for ChangesBenchmark pipeline
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant BenchCompareJob
participant CargoBench
participant Critcmp
participant MainBaseline
participant StepSummary
BenchCompareJob->>CargoBench: run ndarray_ops and save PR baseline
CargoBench-->>BenchCompareJob: benchmark results
BenchCompareJob->>Critcmp: compare PR results with main baseline
Critcmp->>MainBaseline: read main.json
Critcmp-->>BenchCompareJob: comparison output and deltas
BenchCompareJob->>StepSummary: write comparison and noise note
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/mohu-buffer/Cargo.toml (1)
38-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove redundant dev-dependency.
mohu-dtypeis already declared as a regular dependency in this crate (line 19), so it is automatically available to tests and benchmarks. You don't need to declare it again under[dev-dependencies].♻️ Proposed refactor
[dev-dependencies] criterion.workspace = true -mohu-dtype.workspace = true🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/mohu-buffer/Cargo.toml` at line 38, Remove the redundant mohu-dtype entry from the [dev-dependencies] section of Cargo.toml, keeping its existing regular dependency declaration unchanged so tests and benchmarks continue using it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 140-147: Correct the YAML structure for the bench-compare job by
aligning bench-compare with the other top-level jobs under jobs, then indenting
name, runs-on, needs, if, continue-on-error, and steps as its properties. Ensure
it is no longer nested within bench-check and the workflow parses without
duplicate keys.
---
Nitpick comments:
In `@crates/mohu-buffer/Cargo.toml`:
- Line 38: Remove the redundant mohu-dtype entry from the [dev-dependencies]
section of Cargo.toml, keeping its existing regular dependency declaration
unchanged so tests and benchmarks continue using it.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 88078c08-f241-48f9-951f-6d64da54373f
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
.github/workflows/ci.ymlCargo.tomlbenches/README.mdbenches/baselines/main.jsonbenches/ndarray_ops.rscrates/mohu-buffer/Cargo.toml
bench-compare's comment and job block were inconsistently indented relative to sibling jobs, risking YAML structural ambiguity. Normalized to match the 2/4/6-space pattern used by other jobs.
What
Adds baseline benchmark capture and a non-blocking CI regression-check job for the
benches/directory. Closes #287.Why
The
benches/directory existed with no documented baseline result, no CI gate to catch performance regressions, and no comparison-target documentation — so a PR could introduce a 10x regression in a core op with no signal, and no one evaluating the project could see how fast it actually is.How
mohu-array(the publicNdArray<T>type referenced in the issue's own example) isn't implemented yet —array.rsis currently empty. Rather than block on that, this benchmarksmohu-buffer, the allocation/layout layerNdArraywill sit on top of, which is fully implemented today. OnceNdArraylands, these benchmarks should be extended to array-level operations.[[bench]]target intomohu-bufferpointing atbenches/ndarray_ops.rs. BenchmarksBuffer::zerosandBuffer::allocat 100 / 10,000 / 1,000,000 elements (f64).critcmp --export(benches/baselines/main.json) — avoids depending on Criterion's internaltarget/criteriondirectory format in CI.benches/README.md: how to run locally, how to compare against the committed baseline, the current baseline table (with a hardware caveat, since this was captured on a shared Codespaces vCPU, not a dedicated benchmark machine), and the intended NumPy-equivalent comparison targets (documented by name for future reference; not executed in CI).bench-compareCI job (PR-only) that runs benchmarks and posts acritcmpcomparison against the committed baseline to the job summary, for human review — mirrors the existing non-blocking pattern used bycoverageandmiriin this workflow. Kept it informational rather than a hard gate since the issue asks for flagging regressions "for human review," not a hard fail.Checklist
cargo test --workspacepassescargo clippy --workspace -- -D warningspassescargo fmt --allappliedCHANGELOG.mdupdated (if user-facing change) — not user-facing, internal tooling onlySummary by CodeRabbit
New Features
Documentation