perf(spectrum): recover occurrence intervals by bounded outward walks - #63
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughInterval-boundary recovery in three Changesocc_lower/occ_upper boundary recovery
Estimated code review effort: 4 (Complex) | ~40 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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: 2
🤖 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/src/index/spectrum.rs`:
- Around line 5106-5161: Add a direct oracle check for occ_upper in
occ_lower_equals_find_boundary_lower by comparing it against find_boundary with
the shares_prefix predicate, instead of only asserting occ_upper(ip) ==
occ_upper(linear). Keep the existing occ_lower/find_boundary comparison, and use
the same unique symbols occ_upper, find_boundary, shares_prefix, and linear/ip
variables so the test explicitly verifies occ_upper’s boundary against the
gallop-based reference.
- Around line 4187-4227: Add #[inline] to the hot-path helper methods occ_lower
and occ_upper in spectrum.rs, since they mirror the existing inlined helper
chain used by find_boundary and are called on the mem_search comparator tail.
Keep the current logic unchanged and apply the attribute directly on each
function definition so the compiler can inline these bounded-walk recovery paths
alongside find_boundary, ref_less, shares, and lcp_at.
🪄 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: 375231b7-97b9-440a-b8d3-6cee677d6c59
📒 Files selected for processing (1)
prmi/src/index/spectrum.rs
Interval recovery galloped find_boundary over the full [0, sa_num) suffix array on every hit, even though real occurrence intervals are tiny (occ p99 == 4). Add occ_lower / occ_upper: bounded linear walks (cap 8) DOWN / UP from the index the caller already reached, delegating only the rare long tail to the galloping find_boundary. - mem_search / mem_search_warmstart: recover from `ip` via occ_lower(ip) / occ_upper(ip) instead of two full-SA gallops. - forward_truncate_below_maximal: recover the crossing interval by walking down from `lo` and up from `hi`, dropping the expensive full-SA find_boundary(0, sa_num, ...) gallop entirely. Byte-identical: occ_lower / occ_upper are seed-independent for a start inside the interval. Gated by occ_lower_equals_find_boundary_lower. chr22 collect: SA probes/read 210 -> 191 median; cold wall ratio ~1.14 -> ~1.05.
ad9d557 to
0213444
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
First of a three-PR stack of upstreamable prmi boundary-search / SMEM-collection perf, each byte-identical to
mainand gated by proptests. Suggested reading order: this PR, thenperf/boundary-search, thenperf/tokenize-amortize.What
Recover a maximal match's SA occurrence interval by bounded outward walks from the insertion point instead of a full-SA gallop.
occ_lowerwalks down andocc_upperwalks up from the index the search already reached, probing each interval position once, and delegate only the tail (past a small linear cap) to the gallopingfind_boundary.mem_search,mem_search_warmstart, andforward_truncate_below_maximalare rewired onto these; the latter also drops its full-SAfind_boundary(0, sa_num, …)gallop.Why
Real occurrence intervals are tiny (occ p99 ≈ 4), so the linear walk resolves ~all of them in a handful of adjacent probes rather than a
log2(sa_num)gallop, cutting SA probes per read.Correctness
Byte-identical.
occ_lower/occ_upperreturn exactly what the gallopingfind_boundarywould (a capped linear scan of a monotone predicate, with a gallop tail), gated byocc_lower_equals_find_boundary_lowerand the existingmem_search/forward_truncate_below_maximaloracle proptests.Summary by CodeRabbit
Performance Improvements
Bug Fixes
Tests