Skip to content

test(bench): expand benchmark parity matrix#43

Merged
polaz merged 2 commits intomainfrom
test/#24-benchmark-suite
Mar 28, 2026
Merged

test(bench): expand benchmark parity matrix#43
polaz merged 2 commits intomainfrom
test/#24-benchmark-suite

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Mar 28, 2026

Summary

  • benchmark decompression on both rust_stream and c_stream inputs for symmetric Rust vs C parity checks
  • document benchmark matrix behavior and issue test: comprehensive benchmark suite against C zstd #24 acceptance mapping in BENCHMARKS.md
  • ignore accidental root artifact file = in .gitignore

Validation

  • cargo fmt -- --check
  • cargo bench -p structured-zstd --bench compare_ffi --no-run
  • cargo clippy -p structured-zstd --benches --features hash,std,dict_builder -- -D warnings
  • cargo build --workspace
  • cargo nextest run --workspace

Closes #24

Summary by CodeRabbit

  • Documentation
    • Expanded decompression benchmark docs to describe symmetric Rust-vs-C decoder comparisons, acceptance checklist across levels/scenarios, inclusion of small-data scenarios, flamegraph usage, and publication of benchmark reports.
  • Chores
    • Added a repo ignore pattern to exclude a new root-level entry and updated benchmark testing setup to run per-source comparisons and emit memory reports.

- benchmark decompression on both rust_stream and c_stream inputs
- document issue #24 acceptance mapping and matrix behavior
- ignore accidental root artifact file '='

Closes #24
Copilot AI review requested due to automatic review settings March 28, 2026 18:52
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ca8beaff-efaa-4579-bf21-3d9d0ea8b68b

📥 Commits

Reviewing files that changed from the base of the PR and between dbc4a30 and 43e184f.

📒 Files selected for processing (2)
  • BENCHMARKS.md
  • zstd/benches/compare_ffi.rs

📝 Walkthrough

Walkthrough

Precomputes Rust- and C-compressed inputs and refactors decompression benchmarks to run per-source via a new helper; updates BENCHMARKS.md to document symmetric Rust-vs-C decompression runs and adds a single .gitignore entry.

Changes

Cohort / File(s) Summary
Ignore Patterns
\.gitignore
Added a repository-root ignore pattern matching / =.
Benchmark Documentation
BENCHMARKS.md
Clarified decompression benchmarks run against two frame sources (rust_stream, c_stream), added Issue #24 acceptance mapping and adjusted example flamegraph command paths.
Decompression Benchmark Refactor
zstd/benches/compare_ffi.rs
Refactored bench_decompress to precompute both Rust- and C-compressed buffers and introduced bench_decompress_source + assert_decompress_matches_reference. Benchmark groups and stage labels now include the source; emit_memory_report's stage param changed from &'static str to &str.

Sequence Diagram(s)

sequenceDiagram
  participant Bench as Criterion
  participant Harness as bench_decompress
  participant Helper as bench_decompress_source
  participant RustEnc as structured_zstd (rust compressor)
  participant CEnc as zstd (C FFI compressor)
  participant RustDec as pure_rust decoder
  participant CDec as c_ffi decoder

  Bench->>Harness: run bench_decompress(scenario, level)
  Harness->>RustEnc: compress_to_vec(level.rust_level)
  Harness->>CEnc: zstd::encode_all(level.ffi_level)
  Harness->>Helper: bench_decompress_source(..., "rust_stream", rust_compressed, ...)
  Harness->>Helper: bench_decompress_source(..., "c_stream", c_compressed, ...)
  Helper->>RustDec: assert_decompress_matches_reference(rust_compressed)
  Helper->>CDec: assert_decompress_matches_reference(rust_compressed) 
  Helper->>Bench: create group "decompress/{level}/{scenario}/{source}/matrix"
  Bench->>RustDec: run pure_rust benchmark on provided compressed bytes
  Bench->>CDec: run c_ffi benchmark on provided compressed bytes
  Note over Bench,Helper: emit_memory_report called with stage "decompress-{source}"
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through bytes both Rust and C,
Two compressed paths for all to see,
I precompute, I check, then run the race,
Benchmarks bloom in measured pace,
A tiny carrot for every case 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: expanding the benchmark parity matrix to include symmetric Rust vs C decompression comparisons, which is the primary focus of the changeset.
Linked Issues check ✅ Passed The PR addresses key benchmarking objectives from issue #24: implements decompression benchmarks for both Rust and C sources [#24], documents the benchmark matrix in BENCHMARKS.md [#24], and validates decoded outputs [#24].
Out of Scope Changes check ✅ Passed All changes are within scope: benchmark parity expansion (decompression source comparison), documentation updates, .gitignore entry for build artifacts, and test infrastructure improvements directly support issue #24 objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/#24-benchmark-suite

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Expands the Criterion parity benchmarks to measure decompression performance symmetrically on frames produced by both the pure-Rust encoder and the C zstd encoder, and documents the resulting benchmark matrix.

Changes:

  • Extend decompression benchmarks to run on two compressed-frame sources (rust_stream and c_stream) per scenario/level.
  • Update BENCHMARKS.md to describe the new decompression matrix and map Issue #24 acceptance criteria.
  • Ignore an accidental root-level artifact named = via .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
zstd/benches/compare_ffi.rs Refactors decompression benchmarks into a helper and runs both Rust/C decoders against both Rust/C-produced frames.
BENCHMARKS.md Documents the expanded decompression matrix and adds an Issue #24 acceptance mapping section.
.gitignore Ignores an accidental root artifact file named =.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@zstd/benches/compare_ffi.rs`:
- Around line 135-155: The decompression benchmarks ("pure_rust" using
FrameDecoder::new() and decode_all and "c_ffi" using
zstd::bulk::Decompressor::new() and decompress_to_buffer) should wrap
inputs/outputs with std::hint::black_box to prevent unwanted compiler
optimization and match the compression benches: inside each b.iter closure call
black_box on the compressed input before passing it to
decode_all/decompress_to_buffer and black_box the result (written or
output/target) before the assert_eq! checks so the benchmark work cannot be
optimized away.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cf315879-b2f2-4b33-bdb5-baf3284b7d61

📥 Commits

Reviewing files that changed from the base of the PR and between 4857f1e and dbc4a30.

📒 Files selected for processing (3)
  • .gitignore
  • BENCHMARKS.md
  • zstd/benches/compare_ffi.rs

- validate decoded bytes against scenario payload before timing
- apply black_box to decompression input/output paths
- fix flamegraph filter example for source-segmented benchmark names
Copy link
Copy Markdown

@sw-release-bot sw-release-bot bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'structured-zstd vs C FFI'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.15.

Benchmark suite Current: 43e184f Previous: 4857f1e Ratio
compress/default/high-entropy-1m/matrix/c_ffi 0.384 ms 0.298 ms 1.29
compress/default/low-entropy-1m/matrix/pure_rust 12.005 ms 10.329 ms 1.16

This comment was automatically generated by workflow using github-action-benchmark.

CC: @polaz

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

@polaz polaz merged commit 29de24a into main Mar 28, 2026
14 of 15 checks passed
@polaz polaz deleted the test/#24-benchmark-suite branch March 28, 2026 19:35
@sw-release-bot sw-release-bot bot mentioned this pull request Mar 28, 2026
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.

test: comprehensive benchmark suite against C zstd

2 participants