Skip to content

perf(kpm): add dedicated kpm_bench.rs Criterion benchmark (#225)#229

Merged
kalwalt merged 2 commits into
devfrom
perf/kpm-bench-225
Jul 16, 2026
Merged

perf(kpm): add dedicated kpm_bench.rs Criterion benchmark (#225)#229
kalwalt merged 2 commits into
devfrom
perf/kpm-bench-225

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 15, 2026

Copy link
Copy Markdown
Member

Closes #225. Adds the KPM-specific Criterion benchmark deferred from #142.

What

crates/core/benches/kpm_bench.rs times a single KpmHandle::kpm_matching query — the per-frame NFT detection path — with the pure-Rust RustFreakMatcher backend, against the pinball reference marker on pinball-demo.jpg. marker_bench only covered barcode/template detection, so this is the first perf-regression signal for the FreakMatcher pipeline.

  • Reuses existing examples/Data fixtures (pinball.fset3 + pinball-demo.jpg + camera_para.dat) — same assets as simple_nft and the KPM regression tests.
  • Setup (ref-data load + handle build) is done once outside the measured loop; only kpm_matching is timed.
  • sample_size=10 + 15 s measurement keeps it runnable in CI without dominating the suite.
  • Registered as a harness = false [[bench]]; BENCHMARKS.md updated.

Baseline

Pure-Rust query on pinball-demo.jpg (2000×1500, release): ~0.30 s median (locally measured). The within-~20% comparison vs the C++ CppFreakMatcher (the #142 goal) is available by building --features ffi-backend and swapping the backend — numbers are hardware-dependent, so this is a cross-validation reference, not a hard CI gate.

Verified

  • cargo bench --bench kpm_bench runs and produces a stable measurement
  • cargo fmt --check clean; strict clippy --bench kpm_bench --all-features -D warnings clean

Part of the Stabilization & DX milestone.

🤖 Generated with Claude Code

kalwalt and others added 2 commits July 15, 2026 19:01
Times a single KpmHandle::kpm_matching query (the per-frame NFT detection
path) with the pure-Rust RustFreakMatcher backend against the pinball
reference marker on pinball-demo.jpg. marker_bench only covered barcode
detection, so this is the first perf-regression signal for the FreakMatcher
pipeline (deferred from #142).

Reuses the existing examples/Data fixtures (pinball.fset3 + pinball-demo.jpg
+ camera_para.dat); ref-data load and handle build are done once outside the
measured loop. sample_size=10 + 15s measurement keeps it runnable.

Baseline: ~0.30 s median for the pure-Rust query on pinball-demo (2000x1500,
release). The within-20% comparison vs the C++ CppFreakMatcher is available
by building with --features ffi-backend and swapping the backend. Registered
as a harness=false [[bench]]; BENCHMARKS.md updated.

Refs #225

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
#225)

BENCHMARKS.md still asserted "there is no dedicated benchmark exercising
the KPM / FreakMatcher path" and framed the #142 within-20% target as
deferred — both contradicted by kpm_bench.rs landing in this PR.

- Rewrite the KPM/NFT section: the bench now exists; document what it
  measures, the fixtures, the criterion config, the run command, and the
  ~0.30 s pure-Rust baseline on pinball-demo (2000x1500).
- Keep the functional parity evidence as supporting context and reframe
  the C++ comparison as a manual opt-in run (--features ffi-backend)
  rather than a deferred/missing check.
- Add a bench inventory table to "Reproducing Benchmarks" (previously
  only simd_bench was mentioned).
- Refresh the Last Updated stamp.

Refs #225

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kalwalt
kalwalt merged commit 42b5685 into dev Jul 16, 2026
22 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Plan to port KPM to rust Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant