Repository navigation
perf(index): stream bitmap segments sequentially during merge - #9633
Conversation
There was a problem hiding this comment.
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.
| /// 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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
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_segmentson LabelList segments, median of 3 runs,c42e112077vs6bb0377df7: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.