Commit Graph

77 Commits

Author SHA1 Message Date
Tim Visée
d48cd31a36 Add optimizer for many deleted points, make aware of deleted points and vectors (#1758)
* Minor collection optimizer cleanup

* Make optimizers better aware of available vs soft deleted points

* Fix incorrect deleted state on proxy segment for double delete

* Rename upsert_vector to upsert_point, because we work with points

* Refactor point methods for more clear and consistent naming

* Replace internal_size in IdTracker with total_point_count

* Keep track of vector deletion count on storage creation

* Add sparse index optimizer, to optimize indexes with high deletion count

* Add minimum vector count threshold to sparse index optimizer

* Add sparse index optimizer test

* Use consistent naming, write vector in full everywhere

* Simplify vacuum optimizer a bit

* Merge sparse index optimizer into vacuum optimizer

* Improve update_from in segment builder by returning early

* More accurately count vectors in segment optimizer

* Remove random from vacuum optimizer tests to make them more reliable

* Don't expose the total points in segment info, use available points

* Process review feedback

* Compare available vectors against indexed ones in vacuum optimizer

This is much better than using the number of soft-deleted vectors when
the segment was created for calculations. Not to mention that value had
other problems as well.

* Remove create_deleted_vector_count field, update vacuum test parameters

* Potentially solve out of bound panic when building index

* Review fixes:

- Propagate deleted flags into payload hnsw building
- Use `total` number of points for building HNSW instead of number of
  available points
- minor refactoring of `hnsw_config` copy -> clone
- Better detection of `indexed_points` in HNSW

* fix assert condition

* Optional named vectors optimizer reveiw 2 (#1794)

* review with Ivan

* fmt

* remove available_vector_count from segment entry

* remove total_point_count from segment entry

---------

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>

* rollback changes in deleted count in proxy segment

* improve vector threshold detection logic in optimized_segment_builder

* style changes

* fix propagate deleted points to vectors

* Fix typo in method name

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
2023-04-28 10:36:58 +02:00
Tim Visée
9873ac88ec Make query planner aware of deleted points and vectors (#1757)
* Exclude deleted vectors from HNSW graph building stage

* When estimating query cardinality, use available points as baseline

We should not use the total number of points in a segment, because a
portion of it may be soft deleted. Instead, we use the available
(non-deleted) points as baseline.

* Add plain search check to unfiltered HNSW search due to deleted points

* Cardinality sampling on available points, ignore deleted named vectors

* Estimate available vectors in query planner, now consider deleted points

In the query planner, we want to know the number of available points as
accurately as possible. This isn't possible because we only know the
number of deletions and vectors can be deleted in two places: as point
or as vector. These deletions may overlap. This now estimates the number
of deleted vectors based on the segment state. It assumes that point and
vector deletions have an overlap of 20%. This is an arbitrary
percentage, but reflects an almost-worst scenario.

This improves because the number of deleted points wasn't considered at
all before.

* Remove unused function from trait

* Fix bench compilation error

* Fix typo in docs

* Base whether to do plain search in HNSW upon full scan threshold

* Remove index threshold from HNSW config, only use full scan threshold

* Simplify timer aggregator assignment in HNSW search

* Remove vector storage type from cardinality function parameters

* Propagate point deletes to all its vectors

* Check for deleted vectors first, this makes early return possible

Since point deletes are now propagated to vectors, deleted points are
included in vector deletions. Because of that we can check if the vector
is deleted first so we can return early and skip the point deletion
check.

For integrity we also check if the point is deleted, if the vector was
not. That is because it may happen that point deletions are not properly
propagated to vectors.

* Don't use arbitrary vector count estimation, use vector count directly

Before we had to estimate the number of vectors (for a named vector)
because vectors could be deleted as point or vector. Point deletes are
now propagated to vector deletes, that means we can simply use the
deleted vector count which is now much more accurate.

* When sampling IDs, check deleted vecs before deleted points

* On segment consistency check, delete vectors for deleted points

* Fix vector delete state not being kept when updating storage from other

* Fix segment builder skipping deleted vectors breaking offsets

* update segment to handle optional vectors + add test (#1781)

* update segment to handle optional vectors + add test

* Only update stored record when deleting if it wasn't deleted already

* Reformat comment

---------

Co-authored-by: timvisee <tim@visee.me>

* Fix missed vector name test, these are now marked as deleted

* upd test

* upd test

* Update consensus test

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-25 14:31:04 +02:00
Tim Visée
f5a14449a0 Add vector specific quantization configuration (#1680)
* Add QuantizationConfigDiff type

* Add quantization config diff to vector parameters

* Prefer vector config over collection config for quantization

* Update OpenAPI specification

* Validate quantization configuration quantile in 0.5-1.0 range

As per https://github.com/qdrant/qdrant/pull/1681

* Add test if check if vector specific quantization config is persisted

* Alias quantization to quantization_config in vector parameters

* Remove quantization config diff, use full vector specific config instead

* Regenerate OpenAPI specification and gRPC docs

* Fix compilation error

* Add error handling to quantization config conversions

* Fix quantization integration test, make HNSW test stricter
2023-04-10 21:39:43 +02:00
Tim Visée
b7c1ecfd5f Add vector specific HNSW configuration (#1675)
* Validate VectorConfig/VectorParams, remove obsolete validation

* Add HNSW config diff to vector parameters

* Validate params in collection config

* Add HNSW config to segment vector data config

* Add VectorsConfig params iterator for more elegant conversions

* Prefer vector HNSW config over collection config for building HNSW index

* Base segment vector param HNSW config on collection config

* General improvements

* Rewrite HNSW ef_construct extract function to also consider vector configs

* Update OpenAPI specification

* Add test to check if vector specific HNSW config is persisted

* review changes

* review changes

* Regenerate gRPC docs

* Fix test on Windows

* Regenerate OpenAPI specification

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-04-10 17:16:56 +02:00
Andrey Vasnetsov
e034b0ea35 Try to fix dying shards (#1682)
* use common channel pool for healthcheck requests

* add dynamic channel pool

* fmt

* lower parallel connections num

* fmt

* fix clippy

* fix clippy

* better status error message

* smarter channel dropping conditions

* per-channel stats

* refactor pool

* rollback dockerfile

* health-check timeout

* prevent reporting last active peer as dead

* introduce update rate limit

* only rate-limit client requests

* ability to save snapshot without locking wal (#1685)

* ability to save snapshot without locking wal

* fix empty wal saving

* skip waiting on local shard in listener mode even if it is a direct request to listener shard

* snapshot recovery test + better handling of segment versions

* use latest wal

* review changes
2023-04-10 15:29:39 +02:00
Ivan Pleshkov
faf1235333 Remove deleted flags from vector storage (#1561)
* remove deleted flags from vector storage

* remove deleted flags from mmap

* new simple vector storage format

* are you happy clippy

* remove id_tracker from raw_scorer

* revert vector storage format changes

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-15 14:05:07 +01:00
Ivan Pleshkov
2be8590968 Enum vector index (#1539)
* separate payload and vector index bases

* vector index as enum
2023-03-12 14:14:21 +01:00
Ivan Pleshkov
84e6cd8290 Vector storages enum (#1533)
* separate scoring and data containing

* vector storage enum

* fix test build

* are you happy clippy

* review fixes
2023-03-09 09:43:20 +04:00
Ivan Pleshkov
5174388ab4 integrate quantized data to storages (#1311)
* integrate quantized data to storages

* revert gitignore

* are you happy clippy

* quantize in optimizer

* provide flag

* fix segfault

* skip quantization flag, update scores

* use quantization flag

* are you happy fmt

* use quantization flag

* quantized search test

* are you happy fmt

* refactor test, refactor scorer choosing

* are you happy fmt

* run quantization on segment builder

* decrease testing parameters

* simplify segment

* update version

* remove use_quantization flag

* provide quantization config

* quantization version up

* euclid dist

* add euclid test

* saveload

* fix initialization bugs

* quantization lib version up

* fix arm build

* refactor scorer selecting

* quant lib version up

* are you happy fmt

* are you happy fmt

* are you happy clippy

* add save/load test for simple storage

* add comments

* quantiles

* quantization mmap

* remove f32

* mmap test

* fix mmap slice

* fix mmap test

* use chunks for quantization storage

* fix build

* are you happy fmt

* update quantization library

* update quantization lib

* update quantization lib

* integrate api changes

* are you happy fmt

* change quantization api

* additional checks in tests

* update quantization version

* fix unit tests

* add quantization to storage config

* use quantization for all cardinality search cases

* Integrate quantization suggestions 2 (#1520)

* review api

* wip: refactor quantization integrations

* wip: refactor quantization integrations

* wip: fmt

* include quantization into snapshot

* fmt

---------

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-03-03 17:46:17 +01:00
Arnaud Gourlay
4c0f849749 Clippy rust 1.67 (#1406)
* inline format! args

* inline format! args

* explicit lifetime could be elided

* fmt
2023-01-26 17:48:52 +01:00
Arnaud Gourlay
8c2c4f08eb Remove some blocking IO calls on Tokio threads (#1366) 2023-01-19 07:58:45 +01:00
Andrey Vasnetsov
0c1833db7f Disable extra segments checks (#1352)
* optional segment check

* alternative implementation
2023-01-16 12:05:32 +01:00
Roman Titov
ced0abb4c7 Fix segment snapshotting (#1321) (#1334)
* WIP: Fix `Segment::take_snapshot`

TODO:
- This commit, probably, breaks snapshotting of segments with memmapped vector storage
- `ProxySegment::take_snapshot` seems to potentially similar bug

* WIP: Fix `Segment::take_snapshot`

- Fix snapshotting of `StructPayloadIndex`
- Fix snapshotting of segments with memmapped vector storage
- Temporarily break `ProxySegment::take_snapshot`

* Fix `ProxySegment::take_snapshot`

* Remove `copy_segment_directory` test

* nitpicking

* clippy fixes

* use OperationError::service_error

* Cleanup `TinyMap` trait bounds and derive `Debug`

* Fix `test_snapshot` test

- Derive `Debug` for `NamedVectors`

* Move utility functions from `segment.rs` to `utils` module

* Contextualize `segment::utils::fs::move_all` a bit more carefully

* Fix a typo

* add backward compatibility with old snapshot formats

* fmt

* add snapshot for compatibility test

* git lfs is a piece of shit

* Nitpicking

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-01-13 11:44:42 +01:00
Arnaud Gourlay
72dadee806 Repair segment data while checking consistency (#1314)
* Repair segment data while checking consistency

* code review

* code review

* code review

* code review drop_by_internal_id

* refactoring

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2023-01-10 20:02:43 +01:00
Arnaud Gourlay
d77debf122 Clippy for Rust 1.66 (#1284) 2022-12-16 10:53:51 +01:00
Andrey Vasnetsov
aeba32ba3e Shard build refactoring (#1280)
* refactor some code of shard creation and optimizers

* Shard build refactoring debug (#1279)

* add debig code

* debug code

* debug code

* debug code

* debug code

* debug code

* debug code

* debug code

* debug code

* debug code

* debug code

* refactor stop-checking during the optimization

* remove debug logs

* improve delete-renaming schema

* fmt

* move collection file removing to the async task

* rename check_optimization_stopped into more general check_process_stopped
2022-12-14 10:11:46 +01:00
Andrey Vasnetsov
0925d02667 include backtrace for service errors (#1256) 2022-12-06 12:31:38 +01:00
Ivan Pleshkov
ac9538d5af Hnsw links memmap (#1211)
* add on disk key

* remove obsolete graph initialization

* remove obsolete max level

* update openapi

* graph links trait

* use mmap option

* same format for ram and mmap

* fix segment unit tests

* are you happy fmt

* are you happy clippy

* fix ci and add mmap test

* review fixes

* remove unused try-from

* fix version compatibility

* avoid loading from disk during conversion

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-11-25 11:47:52 +01:00
Ivan Pleshkov
017df52528 Use less ram for id tracker (#1176)
* use less ram for id tracker

* are you happy clippy

* use vec for internals

* use versions for internal ids

* keys test

* Use less ram for id tracker fixes (#1182)

* WIP: internal_to_version

* fmt

* fix unit tests

* add comment

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-10-31 10:44:00 +04:00
Andrey Vasnetsov
54e0857708 ignore points with missing expernal ids instead of panic (#1109) 2022-10-24 12:33:43 +02:00
Ivan Pleshkov
f6b2186193 [WIP] Many named vectors per point (#958)
* many named vectors per point (segment-level)

* operation result for dim function

* beautifulized vector name

* fix naming bug

* segment version migration

* fmt

* add segment tests

* are you happy clippy

* fix build

* [WIP] many named vectors per point (collection-level) (#975)

* config and search

* fix placeholders for proxy segment move

* remove VectorType from collection

* are you happy fmt

* vectors in grps messages

* create collections with vectors

* segment holder fixes

* are you happy fmt

* remove default vector name placeholders

* are you happy fmt

* are you happy clippy

* fix build

* fix web api

* are you happy clippy

* are you happy fmt

* record vector&vectors

* openapi update

* fix openapi integration tests

* segment builder fix todo

* vector names for update from segment

* remove unwrap

* backward compatibility

* upd openapi

* backward compatible PointStruct

* upd openapi

* fix record back-comp

* fmt

* vector configuration backward compatibility

* fix vetor storage size estimation

* fmt

* multi-vec segment test + index test

* fmt

* api integration tests

* [WIP] Named vectors struct (#1002)

* move to separate file

* named vectors as struct

* use cow

* fix build

* keys iterator

* avoid copy in PointStruct -> get_vectors

* avoid another copy

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-09-11 20:59:23 +02:00
Andrey Vasnetsov
b9eee55a9f Full text search (#963)
* allow additional params for payload field index

* fmt

* wip: full text index building

* fmt

* text search request

* text search request

* full text index persitance and loading

* fmt

* enable fts index in mapping

* clippy

* fix tests + add integration test

* review fixes: extend payload index test

* revert incedental change
2022-09-01 12:50:12 +02:00
Andrey Vasnetsov
be38254ee8 small refactoring (#746)
* small refactoring

* fix tests
2022-09-01 12:36:28 +02:00
Ivan Pleshkov
f9fb0777a0 Wrap rocksdb column usages (#951)
* wrap rocksdb column usages

* remove obsolete comments

* are you happy clippy
2022-08-22 09:41:08 +02:00
Ivan Pleshkov
f357bd5d9b Allow to flush segment in separate thread (#927)
* allow to flush segment in separate thread

* flush as separate function (#928)

* flush as separate function

* review suggestion

* reduce locks during vector scoring

* fmt

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>

* don't run background flush twice

* Update lib/segment/src/segment.rs

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>

* increase flush interval

* Update lib/segment/src/segment.rs

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

* are you happy fmt

* test background flush

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2022-08-15 13:47:52 +04:00
Russ Cam
8e1f2ca353 Use tempfile (#922)
This commit replaces tempdir with tempfile.
tempdir is archived.

Closes #544
2022-08-10 09:39:21 +02:00
Andrey Vasnetsov
70317d1bbc check for segment integrity by checking the version, skip on failure (#904) 2022-08-03 17:39:13 +02:00
Egor Ivkov
026bd040b0 Add import formatting rules (#820)
* Add import formatting rules

* Review fix: update rusty hook
2022-07-15 15:42:25 +03:00
Egor Ivkov
ef3c6c5e15 Fair hash ring (#816)
* Fair hash ring

* Python test processes removal fix
2022-07-14 19:27:53 +02:00
Andrey Vasnetsov
850e937c2a Storage points tracking refactoring (#750)
* segment refactoring

* rm points iterator

* fmt
2022-06-27 15:17:09 +02:00
Gabriel Velo
c15981092a [WIP] [real-time index] Implement payloadstorage for structpayloadindex (#642)
* [real-time index] Extend FieldIndex enum and StructPayloadIndex with method from PayloadStorage

* [real-time index] add missing remove_point methods

* [real-time index] add new index to FieldIndex enum

* fix compile

* are you happy fmt

* merge load and remove

* fix test generics

* decrement points count

* remove from histogram

* simplify histogram usage

* [real-time index] remove old tests and fix clippy warnings

* histogram: method to derive range by size (#657)

* [real-time index] add histogram based payload_blocks implementation.

* payload blocks

* fmt

* clippy

* [real-time index] refactor Segment to use PayloadIndex instead of PayloadStorage.

* fix tests

* fmt

* clippy

* rename indexes

* remove redundent params

* add struct payload deletion test + fix delete payload in map index

* remove payload threshold

Co-authored-by: Ivan Pleshkov <pleshkov.ivan@gmail.com>
Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-06-06 17:14:20 +02:00
Andrey Vasnetsov
1b458780eb On disk payload storage (#634)
* implement on-disk payload storage

* fmt + clippy

* config param for on-disk payload storage

* upd openapi definitions

* add integration test with on-disk payload

* fix clippy

* review fixes

* fmt
2022-06-01 17:23:34 +02:00
Andrey Vasnetsov
54a66844c5 add version to the segment (#640)
* add version to the segment

* add collection version saving

* Update lib/collection/src/lib.rs

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>

* Update lib/segment/src/segment.rs

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>

* remove self

* add comment

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>
2022-05-31 14:16:49 +02:00
Ivan Pleshkov
effb79733d Unite rocksdb of segment (#585)
unite rocksdb for segment
2022-05-13 17:06:07 +04:00
Andrey Vasnetsov
bc6df8bd12 Better use of column index (#461)
* fmt

* remove redundent condition checker

* remove condition_checker from test

* fmt

* enum_dispatch for payload storage

* rm unused imports

* fmt

* replace enum_dispatch with manual stuff

* fmt

* filter optiizer

* cargo fix

* fmt

* refactor callback approach to payload checking

* cargo fix

* cargo fix

* fix

* fmt

* more filtering condition random fixture types

* clippy

* fmt

* restore lost value counts test

* Update lib/segment/src/index/query_optimization/optimized_filter.rs

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

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2022-04-19 16:04:55 +02:00
Andrey Vasnetsov
ef67a2ec59 Condition search benchmark (#435)
* decouple payload index and vector storage

* wip: test fixtures

* conditional search benchmark

* fmt

* use arc iterator for filtered queries

* fmt

* enable all benches

* fix warn

* upd tests

* fmt

* Update lib/segment/src/fixtures/payload_context_fixture.rs

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>

* Update lib/segment/src/payload_storage/query_checker.rs

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>

Co-authored-by: Egor Ivkov <e.o.ivkov@gmail.com>
2022-04-11 17:43:02 +02:00
Gabriel Velo
c29c9a46d4 [json storage] Filtering context (#413)
* [WIP] add a basic filtering context scaffold

* add PlainFilterContext and StructFilterContext
2022-03-31 08:57:18 -03:00
Gabriel Velo
f69a7b740f json as payload (#306)
add json as payload
Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-03-21 07:09:10 -03:00
Andrey Vasnetsov
e45379e438 Better optimizer error reporting + small bug fixes (#316)
* optimizer error reporting, decouple data removing, optimizator fix

* fmt

* fmt + clippy

* update openapi
2022-02-16 09:59:11 +01:00
Gabriel Velo
4483ea0d60 fix: #101 Payload type consistency is not enforced. 2022-02-09 11:46:01 -03:00
Andrey Vasnetsov
65787f7f55 UUID as point id (#265)
* wip: u64 -> u128 + serialization tests

* breaking: use more flexible structure for saving point ids

* replace u64 external id type with enum

* update openapi definitions for uuid + fix retrieve point api + bash script tests
2022-01-31 13:18:07 +01:00
Andrey Vasnetsov
0f91c9a5e2 [WIP] Force optimization stop #31 (#161)
* implement checking stop-flag in the optimization routine

* wip: optimization cancel test

* force optimization stop during the construction of vector index

* fix clippy
2022-01-18 15:06:42 +01:00
Prokudin Alexander
ee461ce0a6 Extend clippy to workspace and fix some warnings (#199)
* Fix clippy in linting workflow

* Add toolchain override flag

* Add components to toolchain installation explicitly

* Add --workspace flag to clippy to check all packages

* Remove unnecessary clones

* remove redundant .clone() calls

* fix wrong arguments order in tests (typo)

* Fix vec! macro usage in test

* Correct redundant assert! usages

* Provide a quick fix for 'unused' test function lint

* fix unsound Send + Sync

* fix clippy complains

* fmt

* fix clippy

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2022-01-17 23:33:26 +01:00
Anton Kaliaev
e196ce025b fix clippy warnings (#175)
* fix clippy warnings

- doc links
- explicit deref
- if instead of match for single bool condition
- combine similar match branches

* revert removal of transmute

* return Some when vec is not empty
2022-01-03 17:28:21 +01:00
Ivan Pleshkov
bcaa160ad8 Remove dyn Metric from vector storage and use generics (#163)
* Remove dyn Metric from vector storage and use generics

* upd benchmark code

* fix benchmark usage

* fmt

Co-authored-by: Andrey Vasnetsov <andrey@vasnetsov.com>
2021-12-31 09:38:33 +01:00
Marcin Puc
c603f0075e Add various refactorings (#118) 2021-11-10 21:32:25 +01:00
Andrey Vasnetsov
bf3d8c2575 data consistency fixes and updates (#112)
* update segment version after completed update only

* more stable updates: check pre-existing points on update, fail recovery, WAL proper ack. check_unprocessed_points WIP

* switch to async channel

* perform update operations in a separate thread (#111)

* perform update operations in a separate thread

* ordered sending update signal

* locate a segment merging versioning bug

* rename id_mapper -> id_tracker

* per-record versioning

* clippy fixes

* cargo fmt

* rm limit of open files

* fail recovery test

* cargo fmt

* wait for worker stops befor dropping the runtime
2021-10-24 18:10:39 +02:00
Alexander Galibey
f3e8194310 Remove AtomicRefCell wrapper for condition checker (#84) 2021-08-03 10:35:55 +02:00
Konstantin
93e0fb5c2c [CLIPPY] Fix the last portion of rules and enable CI check (#53)
* [CLIPPY] Fixed the warning for references of the user defined types

* [CLIPPY] Fix module naming issue

* [CLIPPY] Fix the last set of warnings and enable clippy check during CI

* Moved cargo fmt and cargo clippy into it's own action
2021-07-03 13:12:21 +02:00
Konstantin
0e1a6e1750 [Clippy] Fix a range of warnings (#52) 2021-07-02 17:51:54 +02:00