test(bench): consumer-hotpath microbenchmarks, hinted-spectrum prototypes, thread-local SA-probe counter - #20
Conversation
|
Warning Review limit reached
More reviews will be available in 50 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds a feature-gated C-ABI probe-count API, three hint/table-backed spectrum search implementations with property tests, Criterion benchmarks for mem-search and primitives, and a feature-gated probe-audit example that measures probe counts end-to-end. ChangesSpectrum Search Optimization and Instrumentation
🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
prmi/benches/primitives_bench.rs (1)
133-144: ⚡ Quick winConsider guarding against very small reference lengths.
The block benchmark will panic if
sa_num < block(i.e., ifPRMI_BENCH_REFLENis set to less than 256). With the default 2M reference this is never an issue, but adding a simple guard would make the benchmark more robust.🛡️ Suggested guard
for &block in &[16usize, 256usize] { + if sa_num < block as u64 { + continue; // skip if reference too small for this block size + } let start = sa_num.saturating_sub(block as u64) / 3; // arbitrary in-range start🤖 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 `@prmi/benches/primitives_bench.rs` around lines 133 - 144, The benchmark can panic when sa_num < block (small reference lengths); before computing start/use of block in the loop over blocks (the for &block in &[16usize, 256usize] loop) add a guard that skips or adjusts the iteration when sa_num is smaller than block (e.g., if sa_num < block as u64 { continue } or choose a smaller block), so that idx.sa_positions(black_box(start), black_box(&mut out)) is only called with a valid start and out buffer.
🤖 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 `@prmi/benches/mem_search_bench.rs`:
- Around line 177-201: The forward-repeat corpus generation in
build_forward_repeat produces high-occ forward queries but the bench
registration (the unique hinted variants logic around the block that handles
297-323) omits running hinted-repeat forward benches; add a mirrored
hinted-forward benchmark path so high-occ hinted behavior is measured: either
extend build_forward_repeat to emit FwdItem entries with the hint field set for
the repeat matches (using fx.idx.mem_search result m.sa_start) or add a new
builder (e.g., build_forward_repeat_hinted) that returns the same queries with
hint populated, and then register those items in the same way the unique hinted
variants are registered so the bench harness runs both unhinted and hinted
forward-repeat cases (referencing FwdItem, build_forward_repeat, mem_search,
m.sa_start, and CORPUS_SIZE to locate where to add/insert the new benchmark
entries).
In `@prmi/src/index/spectrum.rs`:
- Around line 1749-1761: The code unsafely narrows anchor_len to usize and
computes pivot + anchor_len without checking for overflow/out-of-bounds (see
anchor_len_usize, pivot, p_end and tokenize_32mer usage in this function);
mirror the safe behavior from mem_search_backward_from_hint: validate anchor_len
fits into usize (use checked conversion), ensure
pivot.checked_add(anchor_len_usize) and the resulting slice bounds are within
read.len() (return an error/None on failure) and avoid panicking; apply the same
guarded conversion/bounds checks to the other backward prototype around the
p_end computation at the 1822-1824 area.
---
Nitpick comments:
In `@prmi/benches/primitives_bench.rs`:
- Around line 133-144: The benchmark can panic when sa_num < block (small
reference lengths); before computing start/use of block in the loop over blocks
(the for &block in &[16usize, 256usize] loop) add a guard that skips or adjusts
the iteration when sa_num is smaller than block (e.g., if sa_num < block as u64
{ continue } or choose a smaller block), so that
idx.sa_positions(black_box(start), black_box(&mut out)) is only called with a
valid start and out buffer.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a172d913-40cb-4d5d-bf9c-dd34a3ad28f0
📒 Files selected for processing (8)
prmi-sys/Cargo.tomlprmi-sys/src/lib.rsprmi-sys/tests/ffi_probe_count.rsprmi/Cargo.tomlprmi/benches/mem_search_bench.rsprmi/benches/primitives_bench.rsprmi/examples/probe_audit.rsprmi/src/index/spectrum.rs
…ypes, thread-local SA-probe counter
|
@coderabbitai review |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
PR #7 of the v0.2 stack (carries
29bb8de, withd1d8e88folded in per the stack plan). Base isfeat/v0.2-isa-hint(#19). Tracked inV0.2_PR_STACK.mdrow #7.What this does
Benchmarking + profiling harness and the hinted-spectrum prototypes (no production-path behavior change):
mem_search_bench,primitives_bench(consumer-hotpath microbenchmarks).probe_auditexample + thread-local SA-probe counter (prmi_probe_count_*FFI,ffi_probe_count.rs) for measuring search probes per read.d1d8e88(report the modelmax_error_boundin the probe-audit header) is folded in.spectrum.rs(forward/backward "from hint" paths), oracle-tested byte-identical to the cold path (forward_spectrum_from_hint_equals_cold,backward_spectrum_from_hint_equals_cold,backward_stale_hint_is_self_consistent_and_not_longer).Cherry-picked cleanly onto #6 (additive — no conflicts with the carried guards).
Green-pass
-D warnings✅ ·cargo +nightly fmt --check✅ ·cargo test --workspace✅ (162 lib + all integration/FFI; new probe-count + hint-equivalence tests; only Plan-3 deferralsignored).Summary by CodeRabbit
New Features
Tests
Chores