Commit Graph

77 Commits

Author SHA1 Message Date
Jojii
cd8efa8f17 Hw counter utilization checks (#5288)
* Enforce usage of hardware counter values

* improve comments

* log a warning in release mode

* some minor improvements

* avoid cloning for hardware counter

* fmt

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-11-08 11:15:41 +01:00
Jojii
dafe172c49 Add HardwareCounterCell + CPU measurement for sparse vector search (#5239)
* Add HardwareCounterCell and counting for sparse plain search

* Add measurement for indexed sparse vector

* add tests for calculations

* move SegmentQueryContent higher in the call stack

* move hardware counters inside the query context

* fix clippy

* Fix applying hardware measurements and add test for this

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-11-08 11:09:24 +01:00
Arnaud Gourlay
220584251d Downgrade asserts into logs for sparse vector inconsistencies (#5246) 2024-11-08 11:05:39 +01:00
Andrey Vasnetsov
e3b422bdb0 do not fail if posting list does not exist on deletion (#5232) 2024-11-08 11:02:47 +01:00
Andrey Vasnetsov
b3b2279376 Allow explicit populate of mmap (#4923)
* expose mmap populate

* expose mmap populate in open_read_mmap

* FOR TEST, REVERSE IT: make InRamChunkedMmap default

* enable populate advise on unix

* fix clippy

* unix -> linux

* Update lib/collection/src/config.rs

* clippy fixes

* resolve conflicts

* fmt

* Runtime check for PopulateRead

---------

Co-authored-by: xzfc <xzfcpw@gmail.com>
2024-09-17 15:29:32 +02:00
Andrey Vasnetsov
9821368fce initial structures for reading mmap text index (#5029)
* initial structures for reading mmap text index

* creation of text index mmap

* WIP create mmap inverted index

* use same file writing technique as in MmapHashmap

* Save points_to_tokens_count in two files

* clippy

* fill slice with iterator

* review fixes

* fix after review

* implement loading of MmapInvertedIndex

* WIP: prepare for converting ChunkReader into trait

* fmt

* WIP: prepare ChunkReader to be a trai

* WIP: replace ChunkReaderImpl with trait

* implement chunk reader for mmap view

* rollback ChunkReader trait and remove CompressedMmapPostingListView

* move ImmutableInvertedIndex and MutableInvertedIndex into separate files

* impl ops for MmapInvertedIndex

* make mmap hashmap value param generic (#5042)

* make mmap hashmap value param generic

* test + fixes

* Update lib/common/common/src/mmap_hashmap.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

* Update lib/common/common/src/mmap_hashmap.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

* fixups

---------

Co-authored-by: Tim Visée <tim+github@visee.me>
Co-authored-by: xzfc <xzfcpw@gmail.com>

* test and fix immutable to mmap conversion

* fix case 4 and refactor MmapBitSlice::create

* more tests

* fmt

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
Co-authored-by: Tim Visée <tim+github@visee.me>
Co-authored-by: xzfc <xzfcpw@gmail.com>
2024-09-17 15:27:56 +02:00
xzfc
59a372b131 InRamChunkedMmap: optimize using madvise (#4881)
* refactor: introduce AdviceSetting for open_read_mmap/open_write_mmap

* perf: use Advice::Normal in a few places

* perf: use MADV_DONTNEED after reading

* perf: use POSIX_FADV_DONTNEED after reading
2024-08-27 00:57:29 +02:00
xzfc
07c278ad51 Enable some of the pedantic clippy lints (#4715)
* Use workspace lints

* Enable lint: manual_let_else

* Enable lint: enum_glob_use

* Enable lint: filter_map_next

* Enable lint: ref_as_ptr

* Enable lint: ref_option_ref

* Enable lint: manual_is_variant_and

* Enable lint: flat_map_option

* Enable lint: inefficient_to_string

* Enable lint: implicit_clone

* Enable lint: inconsistent_struct_constructor

* Enable lint: unnecessary_wraps

* Enable lint: needless_continue

* Enable lint: unused_self

* Enable lint: from_iter_instead_of_collect

* Enable lint: uninlined_format_args

* Enable lint: doc_link_with_quotes

* Enable lint: needless_raw_string_hashes

* Enable lint: used_underscore_binding

* Enable lint: ptr_as_ptr

* Enable lint: explicit_into_iter_loop

* Enable lint: cast_lossless
2024-08-09 18:10:10 +02:00
xzfc
a5cb30c208 U8 quantization for sparse vector index (#4514)
* U8 quantization for sparse index

* Spelling
2024-06-25 13:33:24 +02:00
xzfc
1a4d8c827a Move build_index out of VectorIndex (#4490)
* Move build_index out of VectorIndex

* Build index in HNSWIndex::open()

* Introduce HnswIndexOpenArgs

* Proper deletion

* Improve tests

* HNSW::open(): add warn, comment and assert

* Revert to making up the config if it does not exist
2024-06-25 13:33:18 +02:00
xzfc
d62a455da1 Integrate compressed posting list (attempt 2) (#4453)
* Rename InvertedIndex* -> InvertedIndexCompressed*

* Extract method VectorIndexEnum::fill_idf_statistics

* Extend VectorIndexEnum with new variants

* Introduce sparse::InvertedIndex::Version

* Replace SparseVectorIndexVersion -> InvertedIndex::Version

* Introduce sparse_vector_index::OpenArgs

* SparseVectorIndex::open: do not build index if directory is empty

Otherwise it would build the index twice since `SegmentBuilder::build()`
calls `::open()`, then `::build_index()`. This restores the old (<=v1.9)
behavior.

* Renames
2024-06-21 23:37:54 +02:00
xzfc
e4b8eb824c Fix: Ignore non-existing postings when deleting old vector (#4472) 2024-06-21 23:35:39 +02:00
Andrey Vasnetsov
df3aa29654 Fix inplace updates for sparse index (#4375)
* include old vector into update function and clean posting lists accordingly

* add integration test

* fix counter

* also remove old vector if the insertion is empty

* clippy

* borrow once

* fix max_next_weight correcton on delete + test

* vector index responsible for updating vector storage

* review fixes

* add debug assert
2024-06-21 23:34:02 +02:00
xzfc
0df90085f2 Make sparse vectors generic (#4364)
* Make sparse vector generic

* Generic search_context tests
2024-06-11 13:16:03 +02:00
xzfc
2a9ce07d93 Sparse: misc fixes (#4361)
* Borrow cows
* Hide sparse_vector_fixture under feature="testing"
2024-06-11 13:14:01 +02:00
xzfc
da68535762 Improve performance of compressed posting list (#4350)
* Improve performance of compressed posting list

* Merge `compressed_idx` and `remainders_idx`
2024-06-11 13:13:44 +02:00
xzfc
e945a6f359 Recreate sparse vector index (#4313)
* Recreate sparse vector index

* Rename index file; add simple migration
2024-06-11 13:13:22 +02:00
Luis Cossío
0cbc6a4578 universal-query: user-facing gRPC and REST request types (#4303)
* add grpc `QueryPoints`

* add rest types

* move to REST types to `api::rest::schema`, decouple `OrderByInterface` and `RecommendStrategy`

* openapi changes

* add score_threshold param

* decouple `ShardKeySelector`, add shard key param

* remove commented-out code

* new codespell
2024-05-26 12:54:25 +02:00
xzfc
3b778fec2b Compressed posting lists (#4253) 2024-05-26 12:50:35 +02:00
xzfc
1d724579df InvertedIndexImmutableRam and index migrations (#4220)
* Move StorageVersion from segment crate to common/io

* Refine StorageVersion API

* Move methods from SparseVectorDataConfig to enum SparseIndexType

* Introduce InvertedIndexImmutableRam

* Add migrate

* Don't migrate
2024-05-26 12:32:50 +02:00
xzfc
49e23ce784 Misc fixes (#4212)
* SparseVectorIndex: replace pub with feature-gated getters

* Fixup dev-dependencies

* Fixup rust doc comments
2024-05-26 12:27:05 +02:00
xzfc
4372ee6915 Update sparse vector benchmarks (#4163) 2024-05-09 14:27:46 +02:00
xzfc
8fe5e43764 Introduce Cargo feature "testing" (#4192) 2024-05-09 14:27:37 +02:00
Andrey Vasnetsov
896cfe109d Sparse idf dot (#4126)
* introduce QueryContext, which accumulates runtime info needed for executing search

* fmt

* propagate query context into segment internals

* [WIP] prepare idf stats for search query context

* Split SparseVector and RemmapedSparseVector to guarantee we will not mix them up on the type level

* implement filling of the query context with IDF statistics

* implement re-weighting of the sparse query with idf

* fmt

* update idf param only if explicitly specified (more consistent with diff param update

* replace idf bool with modifier enum, improve further extensibility

* test and fixes

* Update lib/collection/src/operations/types.rs

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>

* review fixes

* fmt

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2024-05-02 19:16:26 +02:00
Arnaud Gourlay
0cfb3b0e1d Median based TopK for sparse vectors scoring (#4037)
* Median based TopK for sparse vectors scoring

* add test with identical scores
2024-04-22 10:34:41 +02:00
Arnaud Gourlay
3b0d91c22b Fix average sparse vector recommendation (#4047)
* Fix average sparse vector recommendation

* Revert "Fix average sparse vector recommendation"

This reverts commit 186c51209c.

* sort within combine (Ivan's approach)

* Revert "sort within combine (Ivan's approach)"

This reverts commit 28d560cc56.

* simpler approach without mutation
2024-04-22 10:33:47 +02:00
Arnaud Gourlay
6705f81732 Optimize sparse vector index build time (#3605)
* Optimize sparse vector index build time

* rework index builder to reuse posting list builder

* remove unecessary change

* make it shorter
2024-03-05 17:09:03 +01:00
Arnaud Gourlay
02004c8720 Pool larger memory batches for sparse vector search (#3560)
* Pool larger memory batches for sparse vector search

* rework naming

* refine naming

* address great comments

* bump ADVANCE_BATCH_SIZE to use power of 2

* 16k performs bad - trying 8k

* 10k offers the best tradeoff
2024-03-05 17:06:10 +01:00
Arnaud Gourlay
a51275b476 Optimize sparse search by advancing postings without binary search (#3527)
* Optimize search by advancing posting list with binary search

* better name for offset
2024-03-05 17:01:42 +01:00
Arnaud Gourlay
7d6a0972e8 Optimize sparse vector search with batched scoring (#3464)
* Optimize sparse vector search with batched scoring

* replace roaring bitmap by id generation

* compute intersections in Vec instead of Map

* cargo update ahash@0.8.7 --precise 0.8.5

* let rustc handle the pattern match optimization

* profiling done

* remove Option and filter out zero scores

* restore integration test assertion

* filter based on min score to avoid work

* decrease batch size and cleanup posting creation

* remove outdated tests

* remove dead test - I know where to find it if I need it
2024-03-05 16:57:50 +01:00
Arnaud Gourlay
abdb651f7a PostingElement does not need to be Copy (#3479) 2024-03-05 16:55:31 +01:00
Arnaud Gourlay
64a024ba51 Optimize sparse search reaching single posting list (#3424) 2024-03-05 16:49:04 +01:00
Arnaud Gourlay
c6fc008f0e Optimize sparse search by deleting empty postings (#3413) 2024-03-05 16:48:35 +01:00
Arnaud Gourlay
3c87260a01 Optimize sparse vector for real life distribution (#3393) 2024-03-05 16:48:21 +01:00
Arnaud Gourlay
7ceaf73a46 Handle empty sparse vector search (#3368) 2024-03-05 16:46:27 +01:00
Arnaud Gourlay
f92a9af6d8 Optimize inverted index search by tracking min record ids (#3347)
* single pass for min record_id with look-ahead

* Optimize inverted index by tracking min record ids in BinaryHeap
2024-03-05 16:46:23 +01:00
Arnaud Gourlay
3bcb7a5122 Check cancellation after filtering condition to speedup filtered sparse search (#3348) 2024-03-05 16:45:24 +01:00
Arnaud Gourlay
da8eed2af0 Optimize sparse search by precomputing once the query info per posting interator (#3327) 2024-03-05 16:45:15 +01:00
Arnaud Gourlay
d88d654873 Large sparse vectors in test & bench (#3274) 2024-03-05 16:44:07 +01:00
Arnaud Gourlay
b67a6d7f5c Optimize sparse inverted index advance (#3275) 2024-03-05 16:42:17 +01:00
Arnaud Gourlay
680574347f Fix clippy 1.75 (#3270) 2024-01-29 15:23:22 +01:00
Ivan Pleshkov
772a8a75d9 sparse vectors with large indices support (#3230)
* sparse vectors with large indices support

* fix unit tests

* add tracker file to snapshot

* fix unit tests

* are you happy clippy

* fix config loading

* test with max value

* fix python tests

* fix consensus tests

* review remarks; acc test for inverted index
2023-12-19 19:28:13 +00:00
Arnaud Gourlay
2fdab78789 Faster sparse vectors plain search (#3231)
* Faster sparse vectors plain search

* no comments
2023-12-19 19:28:03 +00:00
Ivan Pleshkov
8558399b4e Load non-appendable ram sparse vector index from file (#3154)
* internal sparse vector segment configs

update openapi

fix build

provide correct index type to fixtures

internal sparse vector segment configs

update openapi

fix build

load ram sparse index from file

fix spelling

add test

spelling error

use appendable flag to decide load or not

fix conflict

dont flush mmap when file is empty

* fix build

* set list of files for snapshot

* fix snapshots test

* fix codespell

* simple save-load unit test

* refactor InvertedIndex::files

* fix unit tests

* add debug_assert

* test all persistence loading cases
2023-12-06 22:16:30 +01:00
Ivan Pleshkov
d5a705e0fa Sparse vectors advanced search api support (#3128)
* sparse vectors query scorer

plain search test without internals

fix sparse_vector_index_plain_search

fix async scorer build

fix unit tests

are you happy fmt

sparse index with full query support

fix benches, use exact flag to force plain search

add alias and comment to exact flag

fix tests

recommendations TODOs fix

add simple test

add todo

refactor index

test vs comparison dense and sparse discovery

are you happy fmt

propogate error from avg negatives

reuse filtered points list

rollback api changes

better discovery test

are you happy fmt

rollback openapi

fix build

fix tests

review remark recommendations

review remarks

review remarks

codespell

integrate plain search

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

fix comment of plain search

Update lib/collection/src/recommendations.rs

Co-authored-by: Luis Cossío <luis.cossio@qdrant.com>

fix tests

* simplify search query function
2023-12-06 17:20:42 +01:00
Arnaud Gourlay
67b464174f Plain search by ids in parse vector inverted index (#3161) 2023-12-06 17:20:18 +01:00
Arnaud Gourlay
b0bd9b2bf9 Mmap InvertedIndex uses Sequential madvice (#3092)
* Mmap InvertedIndex uses Sequential madvice

* use madvice Normal

* fix new bench compile after rebase
2023-12-06 17:18:56 +01:00
Arnaud Gourlay
82c08843b4 Fix type for SparseVector converter (#3136) 2023-12-06 17:18:48 +01:00
Ivan Pleshkov
286caac3a4 Sparse index persistence (#3131)
* sparse index persistence

* fix tests

* remove defaults
2023-12-06 17:18:38 +01:00
Arnaud Gourlay
85c96cdd9a Integration tests sparse vector validation (#3122)
* Integration test for sparse vector validations

* cleanup

* clean again
2023-12-06 17:16:12 +01:00