feat(query): minimize deserialize rhs in bitmap functions - #20335
Draft
harry-hao wants to merge 8 commits into
Draft
feat(query): minimize deserialize rhs in bitmap functions#20335harry-hao wants to merge 8 commits into
harry-hao wants to merge 8 commits into
Conversation
- {And}: replace `intersection_with_serialized_unchecked` +
`from_bitmaps` with `intersection_assign_with_serialized_unchecked`
- {Or|Xor|Sub}: replace the deserialize-then-op with in-place ops
over the serialized rhs
Replace `deserialize_bitmap(arg2)` + `std::ops::{BitAnd|BitOr|BitXor|Sub}`
with `*_assign_rhs(BitmapRhs::Serialized)` in `bitmap_logic_operate`.
- And: materialize the smaller side to skip larger rhs - Or/Xor: materialize the larger side for less rhs read - Not: always materialize lhs
…pair scalar bitmap_op_mixed, median: - and(large, small) 11.58 µs -> 2.12 µs - and(small, large) 11.54 µs -> 2.10 µs - not(small, large) 11.12 µs -> 1.85 µs
Contributor
Author
|
@codex review |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
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.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Currently, scalar bitmap AND/OR/XOR/NOT deserialize both operands, and
aggregate OR/XOR/NOT deserialize the rhs, into intermediate treemaps
before operating. This PR minimizes deserialization and operates the
serialized rhs directly to improve performance:
HybridBitmap::apply_rhsdispatches(Or|Xor|Sub, SerializedLarge)to new*_assign_serialized_largeAPIs*_assign_serialized_large*_assign_serialized_largeupdate the treemap in place instead of rebuilding itbitand_assign_serialized_largeandsub_assign_serialized_largebitmap_and/or/xor/notmaterialize one side and pass the other asBitmapRhs::Serializedbitmap_op_largescalar pairwise op bench with large workloadbitmap_op_mixedscalar pairwise op bench with mixed workloadbitmap_not_countaggregate benchUpstream PR status
RoaringBitmap/roaring-rs#361
is ready for review, which provides:
This PR will be marked ready for review after the upstream PR is released.
Performance
Scalar functions:
Aggregates:
difference_assign_with_serializedRoaringTreemap::bitor_assign, whose cost grows with row countKnown limitation: support for run containers
This PR upgrades roaring from 0.10.12 to 0.11.5 to get those new APIs. The new version emits run containers when
insert_rangeoroptimizeis called. Databend does not support run containers, mainly inBitmapReader. This does not impact compatibility, because databend never callsinsert_rangeoroptimize, so run containers will not be created. But this can be a potential optimization for future if we support run container in databend.Tests
Type of change
AI assistance
This change is