perf(spectrum): forward one-shot returns the insertion point, recovers the interval from it - #26
Conversation
…s from it forward_maximal_len now returns (match_len, insertion_point). mem_search recovers the maximal match's SA interval by galloping its lower bound from that insertion point (which sits at the interval's edge) instead of re-looking-up the prefix key and re-searching the model window. Byte-identical by find_boundary's seed-independence (verified by mem_search_equals_maximal_forward_step); the seed only sets the probe count — ~0 for a unique deep match vs ~log2(occ) when a high-occ 32-mer prefix's loose window brackets the wide block. mem_search_backward ignores the insertion point (RC-strand space; the forward p_slice recovery is forward space). The (match_len, ip) return also unblocks the upcoming min_intv-truncated reseed primitive, which needs it. v0.3 perf series.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
Changesforward_maximal_len tuple return refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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.
|
…rd scan (#27) Adds mem_search_backward_truncated_span_rc: the largest left-extension span L in [anchor_len, span_max] whose length-L window occurs >= min_intv times, in ONE call. Walks the reverse-complement strand DOWNWARD from the maximal extension — each left base prepended to the forward pattern is a base appended to its RC, so RC prefixes nest (forward intervals don't) and occ(RC(P)) == occ(P); the interval [lo, hi) is carried across decreasing L by a linear scan capped at min_intv, replacing the binary search that issued a full forward mem_search per step (the consumer's zz_left_span_reseed, ~2.9x fewer SA probes). Model-launched; the .isa-seeded path lands with the interval variant. Byte-identical to the brute-force truncated_span_oracle (new proptest mem_search_backward_truncated_span_rc_equals_oracle). Derives the in-interval seed from forward_maximal_len's insertion point with one shares_prefix probe (#26 returns the insertion point, not the in-interval neighbor). v0.3 perf series.
v0.3 perf series (authored fresh on
main; the perf branch diverged from the merged O(log) internals, so it is re-derived, not cherry-picked).What
forward_maximal_lennow returns(match_len, insertion_point).mem_searchrecovers the maximal match's SA interval by galloping its lower bound from that insertion point (which sits at the interval's edge) instead of re-looking-up the prefix's 32-mer key and re-searching the model window.Why
find_boundaryis seed-independent — the seed only sets the probe count, never the boundary returned. The full query's insertion point is right at the edge of the maximal match's interval, so galloping from it is ~0 probes for a unique deep match, versus ~log2(occ) when a high-occ 32-mer prefix's loose model window brackets the wide block. Net: fewer SA probes on the forward one-shot, byte-identical output.Byte-identity
Verified by the existing
mem_search_equals_maximal_forward_steporacle proptest (mem_search vs an independent brute-forceforward_spectrummaximal step) — a wronglowerwould changesa_startand fail it. All byte-identity oracles pass.Notes
mem_search_backwardignores the insertion point: itsqis the reverse-complement, soipis in RC-strand space while the forwardp_slicerecovery is forward-space (different SA regions) — it can't seed that recovery.(match_len, ip)return also unblocks the upcomingmin_intv-truncated reseed primitive (TRUNC_IV), which needs the insertion point.Self-reviewed with
/coderabbitai-reviewbefore opening (0 findings).Summary by CodeRabbit