Repository navigation
perf: reduce bitmap index build to 1 bitmap in RAM - #6371
Merged
wkalt merged 1 commit intoApr 1, 2026
Merged
Conversation
Contributor
Author
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
wjones127
reviewed
Apr 1, 2026
wjones127
left a comment
Contributor
There was a problem hiding this comment.
Nice work on this!
There are a few unrelated changes to clean up, but after that it's good to merge.
| let keys_array = | ||
| ScalarValue::iter_to_array(self.keys.drain(..).collect::<Vec<_>>().into_iter()) | ||
| .unwrap(); | ||
| let mut binary_builder = BinaryBuilder::new(); |
Contributor
There was a problem hiding this comment.
suggestion: you could presize this builder:
Suggested change
| let mut binary_builder = BinaryBuilder::new(); | |
| let total_size = self.serialized.iter().map(|b| b.len()).sum(); | |
| let mut binary_builder = BinaryBuilder::with_capacity(self.serialized.len(), total_size); |
Although it might be just as efficient to do:
let bitmaps_array: BinaryArray = self.serialized.iter().collect();| vec![ | ||
| Arc::new(StringArray::from(object_ids)), | ||
| Arc::new(StringArray::from(object_types.to_vec())), | ||
| Arc::new(StringArray::from(object_types.clone())), |
Contributor
There was a problem hiding this comment.
issue: these changes in namespace code seem unrelated and unnecessary
| DocType::Text, | ||
| )) | ||
| }) | ||
| .map(|pair| Arc::new(Tokens::new(pair.to_vec(), DocType::Text))) |
Contributor
There was a problem hiding this comment.
issue: this seems unrelated?
Contributor
Author
There was a problem hiding this comment.
hmm, I wonder if my lint fix triggered on this. Will clean this up thanks.
wkalt
force-pushed
the
task/improve-bitmap-build-efficiency
branch
from
April 1, 2026 17:47
2ba0b97 to
746ed60
Compare
…s) to O(1 bitmap) Bitmap index build and update previously materialized every unique value's bitmap in a HashMap before writing to disk. For high-cardinality columns (e.g. URLs with millions of unique values across thousands of fragments) this caused OOM during both initial build and append. Replace the materialize-then-write pipeline with a streaming merge that processes one value at a time: - Request sorted input via TrainingOrdering::Values so the scanner delivers (value, row_id) pairs in value order - Stream through the sorted data, accumulating row_ids for the current value and flushing each bitmap to disk as soon as the value changes - During append, merge-join the sorted new data with the old index's BTreeMap keys, loading each old bitmap on demand and dropping it after write Peak memory drops from O(unique_values * avg_bitmap_size) to O(largest_single_bitmap). On a local benchmark this reduced RSS from 8.6 GB to 3.3 GB and wall time from 20s to 8.5s. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
wkalt
force-pushed
the
task/improve-bitmap-build-efficiency
branch
from
April 1, 2026 18:38
746ed60 to
b1a7c3f
Compare
wjones127
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Bitmap index build and update previously materialized every unique value's bitmap in a HashMap before writing to disk. For high-cardinality columns (e.g. URLs with millions of unique values across thousands of fragments) this caused OOM during both initial build and append.
Replace the materialize-then-write pipeline with a streaming merge that processes one value at a time: