Skip to content

Implement Bits#applyMask in bulk for DenseLiveDocs and SparseLiveDocs - #16593

Open
john-mlika wants to merge 1 commit into
apache:mainfrom
john-mlika:arc-0-livedocs-applymask
Open

Implement Bits#applyMask in bulk for DenseLiveDocs and SparseLiveDocs#16593
john-mlika wants to merge 1 commit into
apache:mainfrom
john-mlika:arc-0-livedocs-applymask

Conversation

@john-mlika

Copy link
Copy Markdown
Contributor

since #15413 live docs read from disk are DenseLiveDocs or SparseLiveDocs, and neither overrides Bits#applyMask, so masking a window by live docs went from a word-wise AND (what FixedBits did) to a get() per set bit. every caller pays it on segments with deletions: AcceptDocs#createBitSet, the four bulk scorers and CheckIndex#bitsCardinality. same hole as #16282, other method

dense delegates to FixedBitSet.andRange, bounded on maxDoc, which is what FixedBitSet#applyMask does. sparse gets a new SparseFixedBitSet.andNotRange, the and-not twin of andRange, that clears the non-zero words of the sparse set out of the window word by word. both are one word op per 64 docs at most, whatever the window holds, and both keep FixedBitSet#applyMask's exception for bits past the end of live docs, which Bits#applyMask now documents

what it costs, LiveDocsBenchmark on an AMD Genoa, one mask over a 1M-doc segment with 1% deletions:

candidates 1% set 10% set 100% set
dense, default 40 µs 445 µs 3592 µs
dense, override 7.6 µs 8.3 µs 7.6 µs
sparse, default 45 µs 543 µs 4237 µs
sparse, override 16 µs 16 µs 16 µs

on #16588's filtered knn benchmark (200k docs, k=100, 95% filter) a query on a segment with 5% deleted docs takes 2.07 ms on main. with only the applyMask override applied it takes 1.44, with only #16588 it takes 1.23, and with both 0.49, which is where the same query sits on a segment without deletions (0.46). the two PRs are halves of one walk, #16588 builds the accept set in bulk and this masks it in bulk, so either alone leaves half the cost. same shape at 0.1% deleted (2.06 -> 0.49 with both) and at 20% (2.22 -> 0.55)

applies to branch_10x too. Relates to #16282 and #16586

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