Skip to content

feat(bench): expand diff-core benchmark with realistic shapes (#29)#48

Merged
Metbcy merged 1 commit into
mainfrom
feat/29-bench-diff-core
May 17, 2026
Merged

feat(bench): expand diff-core benchmark with realistic shapes (#29)#48
Metbcy merged 1 commit into
mainfrom
feat/29-bench-diff-core

Conversation

@Metbcy
Copy link
Copy Markdown
Owner

@Metbcy Metbcy commented May 17, 2026

Closes #29.

What

Rewrites benches/diff.rs to cover realistic diff shapes against the existing axios fixture plus synthetic workloads at 3 sizes × 3 patterns. A 20_000-entry stress run is gated behind a bench-stress cargo feature so the default cargo bench stays under ~30s.

Bench groups

  • axios_fixture_pair — real-world before/after
  • synth/end_to_end/{500,5000} — mixed adds/removes/changes
  • synth/self_diff/{500,5000} — proxy for group_by_key + iteration cost without exposing internals
  • synth/all_license_changed/{500,5000} — worst-case change-heavy path

Sample medians (--quick, laptop)

group median throughput
axios_fixture_pair 1.45µs
synth/end_to_end/500 467µs 2.14 Melem/s
synth/end_to_end/5000 6.25ms 1.60 Melem/s
synth/self_diff/500 399µs 2.51 Melem/s
synth/self_diff/5000 5.50ms 1.82 Melem/s
synth/all_license_changed/500 651µs 1.54 Melem/s
synth/all_license_changed/5000 8.10ms 1.23 Melem/s

Files

  • benches/diff.rs — rewritten (7 bench groups)
  • Cargo.toml[features] bench-stress = []
  • docs/src/architecture.md — "Perf reference: diff core benchmark" section

Verification

  • cargo bench --bench diff --no-run
  • cargo bench --bench diff -- --quick ✓ (1.4s, stable medians)
  • cargo clippy --bench diff --all-features --release -- -D warnings

Notes

  • No public API additions — self_diff is used as a proxy to exercise group_by_key + iteration cost without widening the diff module surface.

@github-actions
Copy link
Copy Markdown

SBOM diff

No dependency changes.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 17, 2026

Coverage report

Line coverage: 84.1% (9378 / 11150 lines)

Full lcov report available as workflow artifact coverage-lcov: download from this run.

v0.9.8 introduces this report; --fail-under-lines will be added once coverage is visible across 2–3 releases.

Closes #29.

The previous benches/diff.rs covered the axios fixture pair and a
200-component synthetic group with a single workload shape. That's
fine as a smoke test but not enough to catch perf regressions in the
diff hot path — especially the kind that wouldn't show up until a
monorepo-scale SBOM lands in production.

This expands the bench to three sizes (500 / 5_000 / opt-in 20_000)
crossed with three workload shapes per size:

- end_to_end: realistic mix (80% unchanged, 10% version_changed,
  5% license_changed, 5% added/removed). Production hot path.
- self_diff: identical inputs. Isolates group_by_key BTreeMap
  construction + per-key traversal with no change-pair work.
- all_license_changed: every intersecting pair has a different
  license set. Isolates the license-comparison branch in
  diff_one_key.

Throughput is reported per group so reviewers can read a regression
as 'X% per component' across sizes vs an algorithmic shape change.

The 20_000-component group is gated behind a new bench-stress cargo
feature so the default 'cargo bench --bench diff' stays under the 30s
budget. On my laptop (--quick mode) the full set runs in ~1.4s; the
default measurement profile fits comfortably under 30s.

docs/src/architecture.md gains a 'Perf reference: diff core
benchmark' section linking benches/diff.rs and stating the >5%
regression threshold for the production end_to_end / 5000 workload,
mirroring the established 'Binary size budget' style.

Verified:
- cargo bench --bench diff --no-run: builds clean.
- cargo bench --bench diff -- --quick: all 7 benches produce stable
  medians (axios + 3 workloads x 2 sizes).
- cargo clippy --bench diff --all-features --release -- -D warnings: clean.
@Metbcy Metbcy force-pushed the feat/29-bench-diff-core branch from 1dd18f4 to e67554a Compare May 17, 2026 23:52
@Metbcy Metbcy merged commit 2db0002 into main May 17, 2026
11 checks passed
@Metbcy Metbcy deleted the feat/29-bench-diff-core branch May 18, 2026 01:29
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.

Add a criterion benchmark for the diff core

1 participant