-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add SIMD-accelerated bulk range evaluation for dense numeric doc values #16050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
77ec451
Add SIMD-accelerated bulk range evaluation for dense numeric doc values
sgup432 5b2e742
Add changelog
sgup432 ecaba41
Minor refactor
sgup432 be25c03
Handle YES_IF_PRESENT case as well in BatchDocValuesRangeIterator
sgup432 2154dc7
Add more unit tests for BlockRangeIterator
sgup432 dab75fc
Fix java docs/comments
sgup432 d75ce13
Merge branch 'main' into simd_doc_values_range
sgup432 ce3cde7
Add nightly version of tests as well
sgup432 e053cd6
Fix build issue
sgup432 afa00a6
Addressing comments - fixed UT logic, added more and refactoring redu…
sgup432 d9cfe96
Merge branch 'main' into simd_doc_values_range
sgup432 c592193
Adding advanceExact implementation for base doc value test class
sgup432 35bfcba
Merge branch 'main' into simd_doc_values_range
sgup432 b08d5a3
Apply suggestions from code review
benwtrent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
46 changes: 46 additions & 0 deletions
46
.../core/src/java/org/apache/lucene/internal/vectorization/DefaultDocValuesRangeSupport.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.lucene.internal.vectorization; | ||
|
|
||
| import org.apache.lucene.util.FixedBitSet; | ||
| import org.apache.lucene.util.LongValues; | ||
|
|
||
| /** Scalar (non-SIMD) implementation of {@link DocValuesRangeSupport}. */ | ||
| final class DefaultDocValuesRangeSupport implements DocValuesRangeSupport { | ||
|
|
||
| static final DefaultDocValuesRangeSupport INSTANCE = new DefaultDocValuesRangeSupport(); | ||
|
|
||
| private DefaultDocValuesRangeSupport() {} | ||
|
|
||
| @Override | ||
| public void rangeIntoBitSet( | ||
| LongValues values, | ||
| int fromDoc, | ||
| int toDoc, | ||
| long minValue, | ||
| long maxValue, | ||
| FixedBitSet bitSet, | ||
| int offset) { | ||
| // Scalar fallback implementation | ||
| for (int d = fromDoc; d < toDoc; d++) { | ||
| long v = values.get(d); | ||
| if (v >= minValue && v <= maxValue) { | ||
| bitSet.set(d - 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
53 changes: 53 additions & 0 deletions
53
lucene/core/src/java/org/apache/lucene/internal/vectorization/DocValuesRangeSupport.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.lucene.internal.vectorization; | ||
|
|
||
| import org.apache.lucene.util.FixedBitSet; | ||
| import org.apache.lucene.util.LongValues; | ||
|
|
||
| /** | ||
| * Interface for SIMD-accelerated doc values range operations. | ||
| * | ||
| * <p>Implementations fill a {@link FixedBitSet} with the doc IDs in a range whose values satisfy a | ||
| * numeric range predicate. The default scalar implementation is used when the Panama Vector API is | ||
| * unavailable; a SIMD-accelerated implementation is used otherwise. | ||
| * | ||
| * @lucene.internal | ||
| */ | ||
| public interface DocValuesRangeSupport { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this support path, etc. all matches our existing patterns. Seems OK to me. |
||
|
|
||
| /** | ||
| * Fills {@code bitSet} with the doc IDs in {@code [fromDoc, toDoc)} whose values (read via {@code | ||
| * values}) are in {@code [minValue, maxValue]}. | ||
| * | ||
| * @param values random-access reader for the doc values | ||
| * @param fromDoc first doc ID to evaluate (inclusive) | ||
| * @param toDoc last doc ID to evaluate (exclusive) | ||
| * @param minValue lower bound of the range (inclusive) | ||
| * @param maxValue upper bound of the range (inclusive) | ||
| * @param bitSet the bitset to fill | ||
| * @param offset subtracted from each doc ID before setting the bit | ||
| */ | ||
| void rangeIntoBitSet( | ||
| LongValues values, | ||
| int fromDoc, | ||
| int toDoc, | ||
| long minValue, | ||
| long maxValue, | ||
| FixedBitSet bitSet, | ||
| int 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this tells me we eventually might actually want a
int count = values.get(int[] docIds, long[] dest);That is a larger change, but I suspect there is perf to be gained lower level just decoding the long values.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benwtrent
Hmm doing in a batched manner like you mentioned would certainly help. Seems like another topic worthy of a separate issue or discussion.