Skip to content

db/datastruct/btindex: simplify interpolation search#21799

Open
AskAlexSharov wants to merge 1 commit into
sudeep/bt-interp-searchfrom
alex/bt-interp-search
Open

db/datastruct/btindex: simplify interpolation search#21799
AskAlexSharov wants to merge 1 commit into
sudeep/bt-interp-searchfrom
alex/bt-interp-search

Conversation

@AskAlexSharov

Copy link
Copy Markdown
Collaborator

Simplification pass on #21794.

  • break on BtInterpBudget exhaustion; the existing binary-search loop below already handles the remaining window, so the m=(l+r)>>1 branch inside the interp loop was dead work.
  • Donate kmBuf to klo/khi instead of append-copying into two separate kloBuf/khiBuf buffers. Since exactly one bound is updated per probe, one scratch buffer is enough; setting kmBuf = nil after donating lets the next g.Next allocate fresh without touching the donated slice.
  • Cache off := b.offt.Get(m) before g.Reset(off) to avoid a second Elias-Fano lookup on key match.
  • Remove the f < 0 / f > 1 guards in interpMid: given klo ≤ key ≤ khi and hi > a, the fraction is always in [0,1]; the m-clamp at the end is the correct guard.
  • u64At: delegate to common.BytesToUint64(k[p:]) (already imported) instead of a manual loop + [8]byte buffer.
  • Trim BtInterp var comment to one sentence per style guide.

- break on BtInterpBudget exhaustion; binary search falls through to the existing loop below
- donate kmBuf to klo/khi instead of two separate copy buffers (zero-copy bound updates)
- cache b.offt.Get(m) before g.Reset to avoid double EF lookup on key match
- remove redundant f<0/f>1 guards in interpMid; m-clamp at end is sufficient
- u64At: delegate to common.BytesToUint64 instead of a manual loop+buffer
- trim BtInterp var comment to one sentence
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.

1 participant