Skip to content

perf(explore): ranked-search materialization via LineOffsetCache#653

Merged
justrach merged 1 commit into
release/0.2.5828from
perf/ranked-line-spans
Jul 4, 2026
Merged

perf(explore): ranked-search materialization via LineOffsetCache#653
justrach merged 1 commit into
release/0.2.5828from
perf/ranked-line-spans

Conversation

@justrach

@justrach justrach commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Third of the round-2 items. The BM25 top-k materialization called extractLineByNumber — a whole-file scan from byte 0 — once per result, up to max_results times per ranked query. Same fix the exact-recall tiers got in #611 and the context sites phase got in #646: resolve hit lines through the LineOffsetCache in O(log n), scanning fallback retained.

Measured (same-session A/B): codedb_context 129.0µs → 113.6µs (−12%) (its keyword loop materializes ranked hits); codedb_search flat on the tiny hit-cached corpus — on real repos each materialized hit was a whole-file walk, so the win scales with file size. Line-slice semantics verified identical (span end-before-newline, final-line-to-EOF, out-of-range → skip, exactly matching extractLineByNumber). Full suite 23/23, 869/873.

🤖 Generated with Claude Code

…ineOffsetCache

The BM25 top-k materialization loop called extractLineByNumber per
result — a scan from byte 0 of the whole file — up to max_results times
per ranked query. Resolve the hit line through the line-offset cache
(O(log n)) exactly like the exact-recall tiers (#611) and the context
sites phase (#646) already do, keeping the scanning path as the fallback
when the offset table can't be built.

Same-session gated bench: codedb_context 129.0µs -> 113.6µs (-12%,
context's keyword loop materializes ranked hits); codedb_search flat on
the tiny hit-cached bench corpus — the win scales with file size on real
repos, where each materialized hit was a whole-file walk. Full suite
23/23 steps, 869/873 (4 platform skips).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05e7b50b2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/explore.zig
var span1: [1]LineOffsetCache.Span = undefined;
const lines1 = [1]u32{c.best_line};
const line_text = blk: {
if (self.line_offsets.lineSpans(path, ref.data, lines1[0..], span1[0..])) |n| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid building full offsets for one ranked hit

When the offset cache is cold, lineSpans builds the complete newline table for ref.data before it can return this single span. This ranked loop passes only the one-element lines1 array, so for a top hit near the beginning of a large file the new path scans and allocates for the entire file, whereas the previous extractLineByNumber stopped as soon as it reached c.best_line. This can regress cold ranked searches or codedb_context on large/generated files; consider keeping the early scan for single-line cold lookups or only using the cache when an entry already exists.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 95514 95394 -0.13% -120 OK
codedb_changes 14275 11967 -16.17% -2308 OK
codedb_context 284301 288460 +1.46% +4159 OK
codedb_deps 372 358 -3.76% -14 OK
codedb_edit 42457 39670 -6.56% -2787 OK
codedb_find 2764 2817 +1.92% +53 OK
codedb_hot 30530 25563 -16.27% -4967 OK
codedb_outline 16243 16462 +1.35% +219 OK
codedb_read 13886 14897 +7.28% +1011 OK
codedb_search 85850 85444 -0.47% -406 OK
codedb_snapshot 71836 64448 -10.28% -7388 OK
codedb_status 13811 9621 -30.34% -4190 OK
codedb_symbol 55952 54713 -2.21% -1239 OK
codedb_tree 42560 13131 -69.15% -29429 OK
codedb_word 12430 14688 +18.17% +2258 NOISE

@justrach justrach merged commit f299cf9 into release/0.2.5828 Jul 4, 2026
2 checks passed
justrach added a commit that referenced this pull request Jul 5, 2026
Bump semver + npm to 0.2.5828 and round out the changelog entry with
the six commits that landed after the draft was written: searchSymbols
binary-insert + total-order tiebreak (#647, #649), word-index persist
integer remap + chunked writes (#650), call-graph reverse adjacency
precompute (#651), snapshot dual-write clone (#652), ranked-search
line-offset resolution (#653), and scripts/bench-ab.sh (#654). No code
changes beyond the version strings + CHANGELOG.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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