Skip to content

perf(rowids): count bitmap bits a word at a time - #8642

Open
pengw0048 wants to merge 1 commit into
lance-format:mainfrom
pengw0048:peng/rowid-bitmap-popcount
Open

perf(rowids): count bitmap bits a word at a time#8642
pengw0048 wants to merge 1 commit into
lance-format:mainfrom
pengw0048:peng/rowid-bitmap-popcount

Conversation

@pengw0048

Copy link
Copy Markdown
Contributor

Problem

Bitmap::count_ones walks the bitmap one byte at a time. A row id sequence
asks for that count on the hot paths:

  • U64Segment::len counts the whole bitmap of a RangeWithBitmap segment, and
    RowIdIndex::new calls len on every segment of every fragment.
  • U64Segment::position counts the bits up to the wanted offset, once per
    lookup.

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 u64 at a time, and keep the byte loop for the trailing bytes and for
the 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 len per segment:

before after
first _take_rows, 1 row id 1.92 s 1.41 s
second call, same dataset object 1.10 s 0.61 s

cargo test -p lance-table --lib rowids: 98 passed.

`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant