Commit Graph

37719 Commits

Author SHA1 Message Date
Anh Dung Bui 30e377a361 Add null check 2024-11-22 09:28:00 +09:00
Anh Dung Bui 8cd3ccf441 Fix doc ord bug & flush writer multiple times 2024-11-21 21:13:24 +09:00
Anh Dung Bui b67637a8d0 Change abstraction to wrap around KNN query 2024-11-21 17:02:14 +09:00
Anh Dung Bui 8d88cab9f2 Store target separately in child class 2024-11-18 15:38:58 +09:00
Anh Dung Bui f9da336ed9 Use Math.ceil instead of rounding 2024-11-18 10:16:49 +09:00
Anh Dung Bui ccd3e25c62 Make the Query experimental 2024-11-17 23:09:18 +09:00
Anh Dung Bui 4e3297191b Add javadoc 2024-11-17 22:53:42 +09:00
Anh Dung Bui e2ab4bcf19 Remove forbidden API 2024-11-17 22:47:10 +09:00
Anh Dung Bui 96d2987349 Remove forbidden API 2024-11-15 15:22:42 +09:00
Anh Dung Bui bbc7081cbc Add tests 2024-11-15 15:15:46 +09:00
Anh Dung Bui edef1b2df6 Initial commit: Add TwoPhaseKnnVectorQuery 2024-11-15 13:16:42 +09:00
panguixin 494b16063e
Replace Map<String,Object> with IntObjectHashMap for KnnVectorsReader (#13763) 2024-10-31 16:16:09 +01:00
Mayya Sharipova 26e0737e40
Account for 0 graph size when initializing HNSW graph (#13964)
When initializing a joint graph from one of the segments' graphs,
 we always assume that a segment's graph is present. But later we want
 to explore an option where some segments will not have graphs (#13447).

This change allows to account for missing graphs.
2024-10-31 10:22:30 -04:00
Adrien Grand 3041af7a94
Speed up advancing within a block, take 2. (#13958)
PR #13692 tried to speed up advancing by using branchless binary search, but while this yielded a speedup on my machine, this yielded a slowdown on nightly benchmarks.

This PR tries a different approach using vectorization. Experimentation suggests that it speeds up queries that advance to the next few doc IDs, such as `AndHighHigh`.
2024-10-30 12:51:36 +01:00
Adrien Grand 9359cfd32f
Speed up Lucene912PostingsReader nextDoc() impls. (#13963)
127 times out of 128, nextDoc() returns the next doc ID in the buffer.
Currently, we check if the current doc is equal to the last doc ID in the block
to know if we need to refill. We can do better by comparing the current index
in the block with the block size, which is a bit more efficient since the
latter is a constant.
2024-10-29 18:16:52 +01:00
panguixin 60ddd08c95
replace Map<String,Object> with IntObjectHashMap for DV producer (#13961) 2024-10-29 16:30:15 +01:00
Adrien Grand 937432acd8
Remove HitsThresholdChecker. (#13943)
`TopScoreDocCollectorManager` has a dependency on `HitsThresholdChecker`, which
is essentially a shared counter that is incremented until it reaches the total
hits threshold, when the scorer can start dynamically pruning hits.

A consequence of this removal is that dynamic pruning may start later, as soon
as:
 - either the current slice collected `totalHitsThreshold` hits,
 - or another slice collected `totalHitsThreshold` hits and the current slice
   collected enough hits (up to 1,024) to check the shared
   `MaxScoreAccumulator`.

So in short, it exchanges a bit more work globally in favor of a bit less
contention. A longer-term goal of mine is to stop specializing our
`CollectorManager`s based on whether they are going to be used concurrently or
not.
2024-10-28 15:50:53 +01:00
Adrien Grand 81ab3b9722 Move CHANGES entry to correct version. 2024-10-26 13:52:55 +02:00
Adrien Grand a3a00f3f58
Remove LeafSimScorer abstraction. (#13957)
`LeafSimScorer` is a specialization of a `SimScorer` for a given segment. It
doesn't add much value, but benchmarks suggest that it adds measurable overhead
to queries sorted by score.
2024-10-26 13:45:54 +02:00
ljak b12ee52999
Ensure stability of clause order for DisjunctionMaxQuery toString (#13944)
Co-authored-by: Laurent <jakubinal@lexum.com>
2024-10-25 18:21:58 +02:00
Adrien Grand 5c080156f5
Disable exchanging minimum scores across slices for exhaustive evaluation. (#13954)
When `totalHitsThreshold` is `Integer.MAX_VALUE`, dynamic pruning is never used
and all hits get evaluated. Thus, the minimum competitive score always stays at
zero, and there is nothing to exchange across slices.
2024-10-25 14:02:04 +02:00
Benjamin Trent 618bfa59a6
Ensure doc order for TestCommonTermsQuery#testMinShouldMatch (#13953) 2024-10-25 07:42:26 -04:00
Shubham Chaudhary bf69c3cf43
Make some BooleanQuery methods public and a new `#add(Collection)` method for BQ builder (#13950) 2024-10-25 13:31:34 +02:00
Adrien Grand 2268242412
Remove some useless code in TopScoreDocCollector. (#13955) 2024-10-25 13:30:49 +02:00
Adrien Grand 8362f609b2
Add MIGRATE entry about the fact that readVLong() may now read up to 10 bytes. (#13956)
This may be of interest for custom `DataInput`/`IndexInput` implementations
that extend `readVLong()`.
2024-10-25 13:30:29 +02:00
Lu Xugang 0bbef32cf5
Check ahead if we can get the count (#13899)
Currently, we traverse the BKD tree or perform a binary search using DocValues first, and then check whether the count can be obtained in the count() method of IndexSortSortedNumericDocValuesRangeQuery.

we should consider providing a mechanism to perform this check beforehand, avoid unnecessary processing when dealing with a sparseRange
2024-10-25 15:05:51 +08:00
Jakub Slowinski 2ec5cc8c17
Removing the deprecated parameters, -fast, -slow, -crossCheckTermVectors from CheckIndex. (#11023) (#13942)
Their usage is replaced with -level with respective values of 1, 3, 3.
2024-10-24 10:46:09 +01:00
Adrien Grand bb3f182251
Introduce a heuristic to amortize the per-window overhead in MaxScoreBulkScorer. (#13941)
It is sometimes possible for `MaxScoreBulkScorer` to compute windows that don't
contain many candidate matches, resulting in more time spent evaluating maximum
scores per window than evaluating candidate matches on this window.

This PR introduces a heuristic that tries to require at least 32 candidate
matches per clause per window to amortize the per-window overhead. This results
in a speedup for the `OrMany` task.
2024-10-22 16:52:36 +02:00
Adrien Grand f8ea130514
Reduce the compiled size of the collect() method on `TopScoreDocCollector`. (#13939)
This comes from observations on https://tantivy-search.github.io/bench/ for
exhaustive evaluation like `TOP_100_COUNT`. `collect()` is often inlined, but
other methods that we'd like to see inlined like `PostingsEnum#nextDoc()` are
not always inlined. This PR decreases the compiled size of `collect()` to make
more room for other methods to be inlined.

It does so by moving an assertion to `AssertingScorable` and extracting an
uncommon code path to a method.
2024-10-22 16:32:28 +02:00
Adrien Grand a779a64d7b
Move BooleanScorer to work on top of Scorers rather than BulkScorers. (#13931)
I was looking at some queries where Lucene performs significantly worse than
Tantivy at https://tantivy-search.github.io/bench/, and found out that we get
quite some overhead from implementing `BooleanScorer` on top of `BulkScorer`
(effectively implemented by `DefaultBulkScorer` since it only runs term queries
as boolean clauses) rather than `Scorer` directly.

The `CountOrHighHigh` and `CountOrHighMed` tasks are a bit noisy on my machine,
so I did 3 runs on wikibigall, and all of them had speedups for these two
tasks, often with a very low p-value.

In theory, this change could make things slower when the inner query has a
specialized bulk scorer, such as `MatchAllDocsQuery` or a conjunction. It does
feel right to optimize for term queries though.
2024-10-21 16:55:04 +02:00
linfn 86457a5f33
Fix StoredFieldsConsumer finish (#13927) 2024-10-21 16:54:13 +02:00
Armin Braun d1e017f192
Speedup OrderIntervalsSource some more (#13937)
Follow-up to #13871, getting another speedup from relatively trivial changes:

* avoid redundant `end()` call by directly storing the end value for sub-iterator that we don't use for anything else
    * also save most `get(...)` calls for this sub-iterator
* avoid redundant `start()` call by grabbing `start()` directly from `nextInterval`
* replace `getFirst()` with `get(0)`, it looks nice but has needless overhead in my testing (not sure why, but profiling clearly shows it to be slower, maybe just a result of having `get()`'s code hot in the cache with a higher likelihood or something esoteric like that)
* avoid using an iterator for loop for a random access list, this is probably the biggest win in this PR
2024-10-21 16:38:12 +02:00
Armin Braun 66f22fa0fd
Simplify PForUtil construction and cleanup its code gen a little (#13932)
Generate cleaner code for PForUtil that has no dead parameters.

Also:
PForUtil instances always create their own `ForUtil`, so we can inline
that into the field declaration. Also, we can save cycles
for accessing the input on PostingsDecodingUtil.

Surprisingly, the combination of these cleanups yields a small but
statistically fully visible speedup that the compiler isn't able to get
to on its own it seems.
2024-10-21 15:10:08 +02:00
Ignacio Vera 05e06e51ec
Use growNoCopy when copying bytes in BytesRefBuilder (#13930) 2024-10-21 07:36:46 +02:00
Michael Sokolov 3983fa2c8d
Add BaseKnnVectorsFormatTestCase.testRecall() and fix old codecs (#13910)
* Add BaseKnnVectorsFormatTestCase.testRecall() and fix map ord to doc in Lucene90HnswVectorsReader
2024-10-17 08:49:56 -07:00
Adrien Grand 1faf33a02a Revert "Better handle dynamic pruning when the leading clause has a single impact block. (#13904)"
This reverts commit 5fd45254d3.
2024-10-16 15:15:06 +02:00
Zhang Chao 789658819f
Remove redundant code in PointInSetQuery (#13905) 2024-10-16 10:33:53 +08:00
Armin Braun 331323f1b9
Avoid slicing memory segments unnecessarily (#13906)
No point in copying the memory segment instances when slicing, they are stateless.
2024-10-15 20:53:54 +02:00
Adrien Grand f69b196ef2
Skip madvise calls on tiny inner files of compound files. (#13917)
This commit skips `madvise` calls on inner files of compound files that are
smaller than the page size.
2024-10-15 16:17:51 +02:00
Adrien Grand 5fd45254d3
Better handle dynamic pruning when the leading clause has a single impact block. (#13904)
`BlockMaxConjunctionBulkScorer` only checks if it can early exit based on
impacts once per window, and windows are computed using impact blocks of the
leading clause. So this logic is defeated if the leading clause produces a
single block (e.g. `ConstantScoreQuery`). This commit addresses this problem by
artificially lowering the window size to contain ~128 docs of the leading
clause.
2024-10-15 16:17:20 +02:00
zhouhui 4d19a5408e
Optimize convert byte2int. (#13889) 2024-10-15 16:12:48 +02:00
Adrien Grand cf29597fec
Make MaxScoreBulkScorer repartition scorers when the min competitive increases. (#13800)
MaxScoreBulkScorer partitions scorers into a set of essential scorers and a set
of non-essential scorers, depending on the maximum scores produced by scorers
and on the current minimum competitive score. An increase of the minimum
competitive score has the potential to yield a more favorable partitioning, but
repartitioning can also be expensive.

In order to repartition when necessary while avoiding to repartition too often,
this PR tracks the minimum value of the minimum competitive score that would
produce a more favorable partitioning, and repartitions scorers whenever the
minimum competitive score exceeds this threshold.
2024-10-15 15:20:34 +02:00
Luca Cavanna 352d85cbe4 Re-enable backwards compatibility tests for version >=10 2024-10-15 15:05:41 +02:00
Luca Cavanna 3d6af9cecc Add back-compat indices for 10.0.0 2024-10-15 14:32:06 +02:00
Adrien Grand e2636c648d
Only call madvise when necessary. (#13907)
This commit tries to save calls to `madvise` which are not necessary, either
because they map to the OS' default, or because the advice would be overridden
later on anyway. I have not noticed specific problems with this, but it seems
desirable to keep calls to `madvise` to a minimum.

As a consequence:
 - Files that are open with `ReadAdvice.NORMAL` do not call `madvise` since
   this is the OS' default.
 - Compound files are always open with `ReadAdvice.NORMAL`, and the actual is
   only set when opening sub files of these compound files.

To make the latter less trappy, the `IOContext` parameter has been removed from
`CompoundFormat#getCompoundReader`.
2024-10-15 14:14:27 +02:00
Luca Cavanna 66bb46f71f Align TestGenerateBwcIndices.java with AddBackcompatindices.py (#13911)
We updated TestGenerateBwcIndices to create int7 HNSW indices instead of int8 with #13874.
The corresponding python code part of the release wizard needs to be updated accordingly.
2024-10-15 13:41:29 +02:00
Luca Cavanna b0170148a1
Forward port "Fix 9.12.0 backcompat break" to main (#13912)
* Fix 9.12.0 backcompat break (Lucene 9.12.0 cannot read 9.11.x indices written with quantized HNSW, `Lucene99HnswScalarQuantizedVectorsFormat`) (#13874)

* carefully regenerate the int8_hnsw bwc indices so that they do in fact use Lucene99ScalarQuantizedVectorsFormat ... when running TestInt8HnswBackwardsCompatibility it now fails (as expected) on 9.11.0 and 9.11.1 bwc indices, but not on 9.10.0

* rename int8 -> int7 bwc tests since we are actually testing 7 bit quantization

* actually fix the bwc bug: only allow compress=true when bits is 7 or 8 in HNSW scalar quantization

* tidy

* Revert "rename int8 -> int7 bwc tests since we are actually testing 7 bit quantization"

This reverts commit eeb3f8a668.

* Reapply "rename int8 -> int7 bwc tests since we are actually testing 7 bit quantization"

This reverts commit 3487c4210b.

* #13880: add test to verify the int7 quantized indices are in fact using quantized vectors not float32

* bump 9.12.x version to 9.12.1 and add bwc indices for 9.12.0

* remove duplicate 9.12.0 Version constant

* revert changes to index.9.12.0-cfs.zip, index.9.12.0-nocfs.zip, sorted.9.12.0.zip

* remove unused bwc index

Closes #13867
Closes #13880

* int7 9.x goes unsupported

---------

Co-authored-by: Michael McCandless <mikemccand@apache.org>
2024-10-15 13:39:33 +02:00
Luca Cavanna 6e9c431f95 Add 10.0.1 section to CHANGES.txt 2024-10-14 22:09:25 +02:00
Luca Cavanna 282945998d Update year in copyright 2024-10-14 17:59:52 +02:00
Armin Braun d5d73d060c
Dry up EverythingEnum and BlockDocsEnum in Lucene912PostingsReader (#13901)
It's in the title, extracting shared parts across both classes.
Almost exclusively mechanical changes with the exception of the introduction
of an array summing util.
2024-10-14 17:29:20 +02:00