PanamaDocValuesRangeSupport: OR mask directly into FixedBitSet instead of per-bit loop#16123
Open
sgup432 wants to merge 2 commits into
Open
PanamaDocValuesRangeSupport: OR mask directly into FixedBitSet instead of per-bit loop#16123sgup432 wants to merge 2 commits into
sgup432 wants to merge 2 commits into
Conversation
…d of per-bit loop
Contributor
|
Nice follow-up! The speedup looks solid! One minor comment, non-blocking: would it be better to move this to a method like |
benwtrent
reviewed
May 26, 2026
Comment on lines
+61
to
+68
| int wordIndex = base >> 6; | ||
| int bitOffset = base & 63; | ||
| long[] bits = bitSet.getBits(); | ||
| if (bitOffset + vectorLen <= 64) { | ||
| bits[wordIndex] |= maskBits << bitOffset; | ||
| } else { | ||
| bits[wordIndex] |= maskBits << bitOffset; | ||
| bits[wordIndex + 1] |= maskBits >>> (64 - bitOffset); |
Member
There was a problem hiding this comment.
my main concern here is correctness. I don't remember from the previous PR, but do we have a test that takes random docs of various densities, etc. and ensures that the "slow iterative path" and "fast path" produce the exact same results?
Member
There was a problem hiding this comment.
Also, I am fine with a new method just on FixedBitSet to achieve this called orBits or orMask or something.
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.
Description
As a followup to one of the comment in this PR - #16050 by @neoremind and @benwtrent, I am adding this change.
Earlier, after the vectorized comparison, we would loop over the matching bits and do bit by bit update on the bitset. This is not needed as ideally we could directly perform a OR operation and set it in the bitset in just one operation.
Also handles the case where if we need to span across two words, for example:
base = 60, and we compared 8 docs together giving the maskBits as
0b10110001.Then docs 60-67 span two words:
Results below. This change gave a further boost in some of the cases!
c5.2xlarge (AVX-512):
Mac (Apple M-series, 128-bit NEON):