Commit Graph

103 Commits

Author SHA1 Message Date
xzfc
a0d62330c7 Use fs-err (#7319) 2025-09-29 12:47:10 +00:00
Andrey Vasnetsov
e86d60e6b0 slow requests log (#7188)
* wip: generalization trait for queries

* implement generalization for point operations

* fmt

* log priority queue

* wip: SlowRequestsListener

* fmt

* fix clippy

* simplify generalization

* fmt

* implement collection of requests profiles for update API

* implement API for viewing slow requests log

* add collection name to update worker

* add datetime to log

* fmt

* probabilistic counter of unique requests

* rename

* compute hash before converting into json value

* move logable out of generalizable

* fmt

* log query request

* fmt

* some fixes

* move measurement into local shard

* fmt

* upd openapi (not important)

* For enum variants, has discriminant

* Make SearchParams Copy

* Hash 0.0 and -0.0 the same

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Correctly hash enum variants and float values

* Hash through ordered float instead

* Fix priority queue not keeping longest request for hash

* SearchParams implements Copy

* Fix clippy warning

* Add unordered_hash_unique

* skip serialization if none

* Use OrderedFloat for hashing a float

* Use OrderedFloat for hashing a float

* only log updates if they are performed

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Tim Visée <tim+github@visee.me>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: xzfc <xzfcpw@gmail.com>
2025-09-19 19:59:25 +02:00
Andrey Vasnetsov
dbe71d44a8 Fix missing flush, flush before sync (#7263)
* add missed flush buffer

* For all BufWriters, wrap owned type and explicitly flush

---------

Co-authored-by: timvisee <tim@visee.me>
2025-09-16 10:34:12 +02:00
Arnaud Gourlay
360d7bc26d Clippy 1.90 (#7253)
* Fix Clippy 1.90

* fmt
2025-09-15 20:12:11 +02:00
Arnaud Gourlay
255dd51e5a Fix Clippy 1.89 (#6981) 2025-08-05 18:06:04 +02:00
Luis Cossío
10de8cc595 [MMR] MMR internals (#6768)
* mmr at local shard

* cleaner impl

* handle timeout

* protect against small input

* fmt

* fix compilation

* add sparse vector raw scorer for volatile storage

* mmr tests

* clippy

* thx coderabbit

* mmr needs a query vector

* fix mmr computation

* don't measure vector_io_read in sparse scorer

* use indexset, and explain why use query score

* coderabbit + small input

* oopsie

* don't remove vectors from points
2025-07-07 16:51:26 -04:00
Roman Titov
bb150a8023 Implement immutable_files method for segment sub-structures (#6637) 2025-06-16 17:32:36 +02:00
Arnaud Gourlay
19a1b08cd6 Fix flaky test_hw_counter_for_plain_sparse_search (#6586) 2025-05-23 11:42:25 +02:00
xzfc
9fedc65bc4 Clear disk cache after read (#6396)
* Move clear_disk_cache to memory::fadvise

* Add memory::fadvise::OneshotFile

* Use OneshotFile
2025-04-17 10:57:47 +02:00
Andrey Vasnetsov
0266508736 disk cache hygiene (#6323)
* wip: implement explicit populate and clear_cache functions for all components

* fmt

* implement clear and populate for vector storages

* fmt

* implement clear and populate for payload storage

* wip: implement explicit populate and clear_cache functions payload indexes

* implement explicit populate and clear_cache functions payload indexes

* fix clippy on CI

* only compile posix_fadvise on linux

* only compile posix_fadvise on linux

* implement explicit populate and clear_cache functions for quantized vectors

* fmt

* remove post-load prefault

* fix typo

* implement is-on-disk for payload indexes, implement clear on drop for segment, implement clear after segment build

* fmt

* also evict quantized vectors after optimization

* re-use and replace advise_dontneed
2025-04-09 10:54:30 +02:00
Andrey Vasnetsov
82af7aa481 vector-io-read measurement on query (#6197)
* remove mut getters from HardwareCounterCell, as mutability is not useful

* introduce vector-io multiplier

* remove RealCpuMeasurement structure

* set vector-io reads multipliers

* account vector reads in dense scorers

* fmt

* fix tests

* propagate hw_counter into posting list iterator

* fmt

* fix test

* wip: measure of sparse iterator

* fmt

* optimize skip_to

* minor refactoring

* keep current PointOffset in iterator to prevent unnecessary reads from memory

* adjust sparse search cpu cost - account for datatype

* fix test

* refactor search_context tests

* move tests into a module

* introduce more tests

* grammar

* review fixes

* fix clippy

* fix clippy again

* change disposable -> new
2025-03-24 13:15:04 +01:00
Tim Visée
3e536347e1 Bump Rust edition to 2024 (#6042)
* Bump Rust edition to 2024

* gen is a reserved keyword now

* Remove ref mut on references

* Mark extern C as unsafe

* Wrap unsafe function bodies in unsafe block

* Geo hash implements Copy, don't reference but pass by value instead

* Replace secluded self import with parent

* Update execute_cluster_read_operation with new match semantics

* Fix lifetime issue

* Replace map_or with is_none_or

* set_var is unsafe now

* Reformat
2025-02-25 11:21:25 +01:00
Arnaud Gourlay
d88e76f90d Fix Clippy 1.85 (#6011)
* Fix Clippy 1.85

* fix false positive
2025-02-18 10:41:28 +01:00
Kumar Shivendu
a407016954 Sparse vectors log (#5992)
* Log when building sparse vectors

* fmt

* log before and after building inverted index

* Add check

* fix number of vectors

* fix log
2025-02-14 21:30:19 +05:30
Luis Cossío
5d9d5bd3f9 Rename blob_store as gridstore (#5918)
* rename blob_store into gridstore

Article is incoming and I feel like gridstore is a better fit to the
architecture

* fmt

* remove outdated TODO
2025-01-30 14:56:34 -03:00
Jojii
5a321d6f09 HwCounter rename IO metrics (#5898)
* Rename io metrics and add vector_io_write

* Chore: Cleanup obsolete TODOs and simplify retrieving HardwareCounterCells (#5899)
2025-01-30 10:23:35 +01:00
Luis Cossío
af74d1b96a bump and migrate to rand 0.9.0 (#5892)
* bump and migrate to rand 0.9.0

also bump rand_distr to 0.5.0 to match it

* Migrate AVX2 and SSE implementations

* Remove unused thread_rng placeholders

* More random migrations

* Migrate GPU tests

* bump seed

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2025-01-28 16:19:11 +01:00
xzfc
12137d2264 Fix cargo doc warnings (#5854) 2025-01-23 09:37:20 +01:00
Roman Titov
6260eb7d74 Cleanup #[allow(dead_code)] annotations (#5818) 2025-01-17 15:37:13 +01:00
Andrey Vasnetsov
b5edc9066b use 64-bit dim-id for storing sparse vectors (#5687)
* use 64-bit dim-id for storing sparse vectors

* allow to disable compression in blob storage

* use bitpack compression instead of lz4

* add basic bench for mmap sparse vector storage

* misc

* bump storage compat pre-release

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2025-01-07 21:45:09 +01:00
Luis Cossío
fa525d2b44 Prefer vector index for size_of_available_vectors_in_bytes (#5587)
* get total sparse size from inverted index

* populate on load if not present

* use debug assertion

* correct size calculation

* r u happy clippy

* fix total sparse size in immutable ram

* don't use options. move size_of_available_vectors to other traits

* adjust test

* fix rebase
2024-12-18 13:04:07 -03:00
Jojii
e0d0e233d8 Timeout aware hardware counter (#5555)
* Make hardware counting timeout aware

* improve test

* rebuild everything

* fmt

* post-rebase fixes

* upd tests

* fix tests

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-12-10 12:12:36 +01:00
Andrey Vasnetsov
2a5b46e780 use fsync instead of flush (#5629) 2024-12-10 00:13:03 +01:00
Luis Cossío
2de122adea Compatibility for mmap sparse vectors (#5454)
* implement mmap sparse vector storage

* add to VectorStorageEnum

* clippy

* add tests, fix both simple and mmap storages

* smol correction on total_vector_count

* add sparse storage type to config

* fix reading config without storage type

* generate openapi

* use blob_store by path

* hidden setting to enable new storage

* validate existing path in `BlobStore::open()`

* use new dir for each sparse vector name

* fix and rename `max_point_offset`

Plus some extra refactors

* add storage compat test, to always check both storages work

* fix opening of storage + other misc fixes

* FIX!!!

`Unset` operations in the Tracker weren't updating the
`next_pointer_id`. So, when reopening the storage, those points wouldn't
get marked as deleted in the bitslice, thus creating the illusion that
they should exist, when they did not.

* refactor naming from `iter_*` to `for_each_*`

* fix checking for BlobStore existance

* fix typo

* fix error message

* better docs for open_or_create

* fix after rebase
2024-11-27 11:45:16 -06:00
Arnaud Gourlay
b6caf4e55b Clippy 1.83 (#5513)
* Clippy 1.83

* there is more
2024-11-27 11:24:58 +01:00
Andrey Vasnetsov
63d2e764f4 batch increment of counter (#5331)
* batch increment of counter

* move cpu counter to posting list level

* prefer incr_delta_mut
2024-10-30 13:59:25 +01:00
Jojii
98ef428878 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-10-25 09:52:18 +02:00
Jojii
73a785f145 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-10-17 16:24:13 +02:00
Arnaud Gourlay
b6a58c9bef Downgrade asserts into logs for sparse vector inconsistencies (#5246) 2024-10-16 10:56:31 +02:00
Andrey Vasnetsov
f964e02730 do not fail if posting list does not exist on deletion (#5232) 2024-10-15 09:45:54 +02:00
Andrey Vasnetsov
e8d5cfc63c 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-14 20:53:07 +02:00
Andrey Vasnetsov
b342cbca6e 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-10 12:02:05 +02:00
xzfc
0e6f86bdfb 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-14 13:41:37 +00:00
xzfc
a0ea3caccf 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-07-22 08:19:19 +00:00
xzfc
dd3102baeb U8 quantization for sparse vector index (#4514)
* U8 quantization for sparse index

* Spelling
2024-06-24 14:12:29 +00:00
xzfc
cde39fb8a2 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-24 14:44:34 +02:00
xzfc
05ff867ff3 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-17 14:41:38 +02:00
xzfc
409fb73885 Fix: Ignore non-existing postings when deleting old vector (#4472) 2024-06-14 16:13:01 +00:00
Andrey Vasnetsov
3e4c6dc0d3 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-12 12:13:49 +02:00
xzfc
d2ef556237 Make sparse vectors generic (#4364)
* Make sparse vector generic

* Generic search_context tests
2024-06-10 15:04:32 +00:00
xzfc
f4c7ba15af Sparse: misc fixes (#4361)
* Borrow cows
* Hide sparse_vector_fixture under feature="testing"
2024-05-30 20:58:00 +00:00
xzfc
cd808afe3c Improve performance of compressed posting list (#4350)
* Improve performance of compressed posting list

* Merge `compressed_idx` and `remainders_idx`
2024-05-30 13:30:24 +00:00
xzfc
f026fc8a42 Recreate sparse vector index (#4313)
* Recreate sparse vector index

* Rename index file; add simple migration
2024-05-29 17:04:17 +00:00
Luis Cossío
b14d0b2463 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-24 08:23:12 -04:00
xzfc
93a42b4e2d Compressed posting lists (#4253) 2024-05-22 18:18:20 +00:00
xzfc
ccf7f1d24f 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-16 06:47:47 +00:00
xzfc
4f3239f27c Misc fixes (#4212)
* SparseVectorIndex: replace pub with feature-gated getters

* Fixup dev-dependencies

* Fixup rust doc comments
2024-05-10 08:16:28 +00:00
xzfc
6f738ca95f Update sparse vector benchmarks (#4163) 2024-05-07 20:34:37 +00:00
xzfc
cb31c533bf Introduce Cargo feature "testing" (#4192) 2024-05-07 16:14:46 +00:00
Andrey Vasnetsov
c173a9f5e5 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-04-29 14:54:14 +02:00