Skip to content

perf(index): stream bitmap segments sequentially during merge - #9633

Merged
Xuanwo merged 2 commits into
mainfrom
xuanwo/bitmap-merge-sequential-reads
Oct 22, 2026
Merged

Xuanwo merged 2 commits into
mainfrom
xuanwo/bitmap-merge-sequential-reads

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Closes #9632.

Bitmap and LabelList segment merges loaded every source entry with its own single-row range read, one after another. On a high-cardinality column that is one object store round trip per key, so large merges never finish.

When a source's lookup file stores its rows in key order, as current builds do, the merge now streams its bitmaps in one pass and skips the index cache. Unsorted legacy files keep the per-key path.

Benchmark

750x faster on S3: 251 s -> 0.34 s for 10,000 entries (paired runs, 712x-782x).

EC2 c7i.8xlarge and the S3 bucket are both in us-east-2. The table shows merge_existing_index_segments on LabelList segments, median of 3 runs, c42e112077 vs 6bb0377df7:

Entries Base This PR Speedup S3 reads (base / PR)
10K 251 s 0.34 s 750x 10,010 / 12
20M — 27.6 s — — / 232
50M — 72.6 s — — / 558

The base does not scale past ~40 entries/s, so 50M entries would take about two weeks.

Overlaps with #9290, which changes the same merge.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer performance labels Sep 30, 2026
@Xuanwo
Xuanwo marked this pull request as ready for review September 30, 2026 17:45

@claude claude 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Gate recommendation: approve with a non-blocking risk.

Sequential reads address the object-store latency bottleneck while preserving merge semantics. Account for the per-source batch footprint when running wide merges of large postings.

/// be a few bytes on a high-cardinality column or large on a low-cardinality
/// one, so batches stay small; the file reader plans the underlying reads over
/// the whole range, so the batch size does not set the request count.
const MERGE_BITMAP_BATCH_ROWS: u64 = 1024;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The row-count limit can retain substantially more bitmap data per source when postings are large. With caching disabled, a local run with 1,024 postings of 65,732 bytes retained 67,309,568 bytes (about 64 MiB) in reader.batch after the first read, before I/O and decode readahead. This footprint multiplies across sources. This is a non-blocking operating trade-off; smaller decoded batches could reduce it while retaining sequential reads.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Sep 30, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Oct 22, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Gate recommendation: approve with a non-blocking risk.

Sequential reads address the remaining object-store request amplification through the shared build/update cursor. Wide merges with large postings still need headroom for the per-source batch buffers.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Oct 22, 2026
@Xuanwo
Xuanwo merged commit 026137a into main Oct 22, 2026
41 of 43 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/bitmap-merge-sequential-reads branch October 22, 2026 23:06
westonpace pushed a commit that referenced this pull request Oct 23, 2026
…ow_addresses

Main's perf(index): stream bitmap segments sequentially during merge
(#9633) added three BitmapIndex::load call sites using the pre-#9814
3-argument signature. Merging it in left them uncompilable against
this branch's 4-argument load (which added results_are_row_addresses).
Pass true, matching every other freshly-trained-index call site in
this file.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HFbf8RxqsVZ3yyhLwQRSWP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: bitmap and LabelList segment merge issues one object store read per key

2 participants