152 Commits

Author SHA1 Message Date
xzfc
779a66f783 Migrate InvertedIndexCompressedMmap to UIO (#9144)
* Migrate InvertedIndexCompressedMmap to UniversalRead

* Rehaul search_scratch.rs (was scores_memory_pool.rs)

- Use `typed_arena::Arena` instead of `bumpalo::Bump`.
  Reason: bump don't drop.
  Drawback: `Arena::new()` is not free, and `Arena::clear()` doesn't
  exist; but this commit has workarounds.
- Use names that make more sense.

* Misc fixes

* InvertedIndexCompressedMmap: explicit S type parameter
2026-06-03 14:53:11 +02:00
xzfc
3729c62117 Cache sparse benchmark setup (#9141)
* dataset: add features to fs-err

Reason: fix `cargo check --all-targets -p dataset`. Feature unification
pulls `fs-err/debug` + `fs-err/tokio` without `fs-err/debug_tokio`.

* dataset: run `cargo metadata` to get target dir

Reason: avoid re-downloading in separate worktrees. The old
`cargo locate-project` ignores custom target dirs.

* sparse/benches/search: cache vectors/indices
2026-06-03 14:46:35 +02:00
xzfc
a57df81e1f sparse: use zerocopy (#9140)
* sparse: use zerocopy for mmap reads

* loaders::Csr: use zerocopy
2026-06-03 14:45:26 +02:00
xzfc
7035440f4c Error propagation for sparse InvertedIndex (#9076)
* Remove unused InvertedIndexMmap / InvertedIndexImmutableRam

* Error propagation for InvertedIndex trait
2026-05-22 10:44:28 +02:00
xzfc
ba710e1c50 Remove unused InvertedIndexMmap / InvertedIndexImmutableRam (#9074) 2026-05-22 10:44:15 +02:00
Arnaud Gourlay
71ad3ea524 Delete unused code (#8771)
* Delete unused code

* restore initialize_global

* drop BadShardSelection

* Remove now obsolete allow(dead_code) attributes

* Remove more dead code

---------

Co-authored-by: timvisee <tim@visee.me>
2026-05-08 13:47:29 +02:00
Tim Visée
1e8a7a98ec Fix clippy warnings for Rust 1.95 (#8695)
* Remove redundant into_iter

* Remove redundant type casting

* Use if-branches in match

* Use sort_by_key

* Only iterate over values

* Dismiss bench loop counter warning

* done done

---------

Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
2026-05-08 13:46:45 +02:00
Andrey Vasnetsov
d49692457e clearing cache with pageout (#8654)
* use pageout to clear mmap cache

* Also clear cache of deleted flags in mmap dense vector storage

* Add reference to madvise man pages for probe logic

* use deconstruct

---------

Co-authored-by: timvisee <tim@visee.me>
2026-05-08 13:46:42 +02:00
Tim Visée
7e02bd0970 Claude: simplify codebase (#8627)
* [ai] Replace manual into mappings with Into::into

* Reformat

* [ai] Use implicit .iter

* Don't iterate over keys too

* [ai] Replace unwrap_or

* Reformat

* [ai] Use as_deref and then_some

* [ai] Use more to_string

* [ai] Use explicitly typed into conversions

* Reformat

* [ai] More explicit into conversions

* Reformat
2026-05-08 13:46:37 +02:00
Jojii
14ef2b256a Don't insert deferred points into sparse index (#8435)
* Don't insert deferred points into sparse index

# Conflicts:
#	lib/segment/src/segment/tests.rs
#	lib/segment/src/segment_constructor/segment_constructor_base.rs

# Conflicts:
#	lib/segment/src/segment_constructor/segment_constructor_base.rs

* Clippy

* Assert consistency of deferred_internal_id var

* Return before SparseVector conversion in case of deferred point

* Use debug_assert instead
2026-03-26 18:48:47 +01:00
Jojii
b7c69dbcba Filter deferred points sparse search (#8299)
* Implement filtering deferred: Sparse search

* Add tests for deferred sparse vectors

* Clippy

* Review remark
2026-03-26 17:49:52 +01:00
Tim Visée
afe60f143f Use array_windows when statically sized windows were used (#8348)
* Use array_windows when statically sized windows were used

* Bump MSRV to 1.94

* fix in gpu code

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2026-03-26 17:44:32 +01:00
dependabot[bot]
a7739dbf2d build(deps): bump rand_distr from 0.5.1 to 0.6.0 (#8148)
* build(deps): bump rand_distr from 0.5.1 to 0.6.0

Bumps [rand_distr](https://github.com/rust-random/rand_distr) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/rust-random/rand_distr/releases)
- [Changelog](https://github.com/rust-random/rand_distr/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-random/rand_distr/compare/0.5.1...0.6.0)

---
updated-dependencies:
- dependency-name: rand_distr
  dependency-version: 0.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Migrate main code base to rand 0.10

* Migrate tests

* Migrate benches

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: timvisee <tim@visee.me>
2026-03-26 17:09:49 +01:00
xzfc
66d0c36009 Merge io and memory into common (#8155)
* Unify parking_lot/arc_lock feature

* Move lib/common/{io,memory}/* -> lib/common/common/*

- Mmap-related items are grouped into `common::mmap` sub-module:
  - `memory/src/chunked_utils.rs`      -> `common/src/mmap/chunked.rs`
  - `memory/src/madvise.rs`            -> `common/src/mmap/advice.rs`
  - `memory/src/mmap_ops.rs`           -> `common/src/mmap/ops.rs`
  - `memory/src/mmap_type_readonly.rs` -> `common/src/mmap/mmap_readonly.rs`
  - `memory/src/mmap_type.rs`          -> `common/src/mmap/mmap_rw.rs`
- Filesystem-related items are grouped into `common::fs` sub-module:
  - `common/src/fs.rs`          -> `common/src/fs/sync.rs`
  - `io/src/file_operations.rs` -> `common/src/fs/ops.rs`
  - `io/src/move_files.rs`      -> `common/src/fs/move.rs`
  - `io/src/safe_delete.rs`     -> `common/src/fs/safe_delete.rs`
  - `memory/src/checkfs.rs`     -> `common/src/fs/check.rs`
  - `memory/src/fadvise.rs`     -> `common/src/fs/fadvise.rs`
- Rest is moved straight into `common`:
  - `io/src/storage_version.rs` -> `common/src/storage_version.rs`

The old `io` and `memory` are now hollow crates that re-export items
from `common`. These hollow crates will be removed in next commits.

* Replace uses of `io` and `memory` with new paths in `common`

Since `io` and `memory` are just re-exports of `common`, these
replacements are no-op.

* Remove `io` and `memory` crates
2026-02-17 11:01:14 +01:00
xzfc
b1e3e421b0 Chore: promote dependencies to workspace level (#8061)
* Promote `env_logger` to workspace dependency

* Promote `anyhow` to workspace dependency

* Promote `rmp-serde` to workspace dependency

* Promote `tinyvec` to workspace dependency

* Promote `async-trait` to workspace dependency

* Promote `url` to workspace dependency

* Promote `self_cell` to workspace dependency

* Promote `cc` to workspace dependency

* Promote `bitpacking` to workspace dependency
2026-02-10 00:02:45 +01:00
Ivan Boldyrev
d8ffb098c7 Fix gridstore Option unsoundness (#8011)
* Implement `Optional<T>` type

Define a type with the same presumed layout as `Option<T>`, but with defined behavior.

* Make `transmute_*` functions unsafe

The functions `memory::mmap_ops::transmute_*` are inherently unsafe, but
are not marked as are.  Their usage is documented, but it is not always clear
if the code is correct.

* Add `CsrHeader` to resolve another unsoundness

Tuples have no defined layout.
2026-02-09 23:53:02 +01:00
dependabot[bot]
b9bd1e0f5b build(deps): bump bitpacking from 0.9.2 to 0.9.3 (#7935)
Bumps [bitpacking](https://github.com/quickwit-oss/bitpacking) from 0.9.2 to 0.9.3.
- [Release notes](https://github.com/quickwit-oss/bitpacking/releases)
- [Changelog](https://github.com/quickwit-oss/bitpacking/blob/master/CHANGELOG.md)
- [Commits](https://github.com/quickwit-oss/bitpacking/commits)

---
updated-dependencies:
- dependency-name: bitpacking
  dependency-version: 0.9.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-09 23:15:07 +01:00
xzfc
fbb310e633 Put unreliable unsafe block behind "testing" feature flag (#7884) 2026-02-09 22:52:07 +01:00
Luis Cossío
7eda6c62cb activate fs-err features for nicer error messages (#7665)
* activate fs-err features for nicer error messages

* use in entire workspace
2025-12-03 10:23:55 +01:00
xzfc
6a2830db1c Use fs-err (#7319) 2025-11-14 12:26:51 +01:00
Andrey Vasnetsov
1771696d55 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-29 11:31:11 +02:00
Andrey Vasnetsov
916703e1e5 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-29 11:30:25 +02:00
Arnaud Gourlay
b8c567a20d Clippy 1.90 (#7253)
* Fix Clippy 1.90

* fmt
2025-09-29 11:29:50 +02:00
Arnaud Gourlay
118ff6dda3 Fix Clippy 1.89 (#6981) 2025-08-11 13:16:42 +02:00
Luis Cossío
1a6ae6e77e [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-17 13:48:33 +02:00
Roman Titov
422bce5ef0 Implement immutable_files method for segment sub-structures (#6637) 2025-07-17 13:10:08 +02:00
Arnaud Gourlay
7384240fb1 Fix flaky test_hw_counter_for_plain_sparse_search (#6586) 2025-07-17 11:01:54 +02:00
xzfc
1f805b618e Clear disk cache after read (#6396)
* Move clear_disk_cache to memory::fadvise

* Add memory::fadvise::OneshotFile

* Use OneshotFile
2025-04-21 00:08:52 +02:00
Andrey Vasnetsov
6e0ddbafa9 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-20 23:54:40 +02:00
Andrey Vasnetsov
ad4743a85f 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-31 16:19:02 +02:00
Arnaud Gourlay
2737168263 Move Bincode to workspace and comment version lock (#6151) 2025-03-21 11:43:26 +01:00
Tim Visée
8ad2b34265 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-03-21 11:38:56 +01:00
Arnaud Gourlay
798f14cafb Fix Clippy 1.85 (#6011)
* Fix Clippy 1.85

* fix false positive
2025-03-21 11:36:07 +01:00
Kumar Shivendu
8a4f3c7388 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-17 10:21:15 +01:00
Luis Cossío
315a35fe73 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-02-11 14:38:05 +01:00
Jojii
77f65ef95f HwCounter rename IO metrics (#5898)
* Rename io metrics and add vector_io_write

* Chore: Cleanup obsolete TODOs and simplify retrieving HardwareCounterCells (#5899)
2025-02-11 14:37:24 +01:00
Luis Cossío
f110328296 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-02-11 14:36:20 +01:00
xzfc
eaaa31e34d Fix cargo doc warnings (#5854) 2025-01-23 14:29:19 +01:00
Roman Titov
1a4cc22589 Cleanup #[allow(dead_code)] annotations (#5818) 2025-01-23 14:27:56 +01:00
Andrey Vasnetsov
472f8e0a71 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-08 14:11:43 +01:00
Luis Cossío
3725c7c723 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
2025-01-08 14:07:43 +01:00
Jojii
5aee24cc08 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>
2025-01-08 14:03:52 +01:00
Andrey Vasnetsov
4abd77158a use fsync instead of flush (#5629) 2025-01-08 14:01:25 +01:00
Luis Cossío
c10c145a75 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-12-09 11:07:01 +01:00
Arnaud Gourlay
f416f2b98f Clippy 1.83 (#5513)
* Clippy 1.83

* there is more
2024-12-09 11:06:24 +01:00
Andrey Vasnetsov
04f63a6a7f batch increment of counter (#5331)
* batch increment of counter

* move cpu counter to posting list level

* prefer incr_delta_mut
2024-11-08 11:20:43 +01:00
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
Arnaud Gourlay
50a36448cb Promote criterion to workspace (#5291) 2024-11-08 11:11:49 +01:00
Arnaud Gourlay
a749e4dd9f Promote ordered-float to workspace (#5285) 2024-11-08 11:11:32 +01:00
dependabot[bot]
e5ce41c244 build(deps): bump ordered-float from 4.3.0 to 4.4.0 (#5277)
Bumps [ordered-float](https://github.com/reem/rust-ordered-float) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/reem/rust-ordered-float/releases)
- [Commits](https://github.com/reem/rust-ordered-float/compare/v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: ordered-float
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-08 11:11:05 +01:00