perf(rowids): count bitmap bits a word at a time - #8642
Open
pengw0048 wants to merge 1 commit into
Open
Conversation
`Bitmap::count_ones` walked one byte at a time. A row id sequence asks for it twice on every lookup path: `U64Segment::len` counts the whole bitmap of a `RangeWithBitmap` segment, and `position` counts the bits up to the offset.
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.
Problem
Bitmap::count_oneswalks the bitmap one byte at a time. A row id sequenceasks for that count on the hot paths:
U64Segment::lencounts the whole bitmap of aRangeWithBitmapsegment, andRowIdIndex::newcallslenon every segment of every fragment.U64Segment::positioncounts the bits up to the wanted offset, once perlookup.
On a 15.43B row / 17,601 fragment dataset whose sequences hold 3.36 GB of
bitmaps, that byte-at-a-time count is the whole cost of opening the index.
Change
Count a
u64at a time, and keep the byte loop for the trailing bytes and forthe two partial bytes at the ends of a slice.
Measurement
Taking one row id from that dataset, release build, 96-core Linux x86-64. The
index here is the per-fragment index from #8624, which calls
lenper segment:_take_rows, 1 row idcargo test -p lance-table --lib rowids: 98 passed.